Create testing framework for CLI (#453)

* Create testing framework for CLI

- Need to add tsconfig for specs to convert module format and add spec
dir to output
- Use jasmine-ts to test

expected dev cycle would be to have two watchers, one for jslib
and one for CLI tests. We could add jslib tests to this jasmine config,
but it feels wrong to test a submodule

* Run prettier

* Add tests to build pipeline

* Include required package

* Add placeholder test

* Run prettier

* Add nodemon and fix watch
This commit is contained in:
Matt Gibson 2022-01-21 11:28:36 -05:00 committed by GitHub
parent 8b650666c5
commit 21e8db9636
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2173 additions and 77 deletions

View File

@ -132,6 +132,9 @@ jobs:
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test
- name: Build & Package
run: npm run dist

2
jslib

@ -1 +1 @@
Subproject commit 11e7133aefa4443e07febde9b3add25539ec2287
Subproject commit 19bf7c75a369c59328ee602f37570cf1f50f05b6

2212
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -42,7 +42,9 @@
"lint": "tslint 'src/**/*.ts' 'spec/**/*.ts' && prettier --check .",
"lint:fix": "tslint 'src/**/*.ts' 'spec/**/*.ts' --fix",
"prettier": "prettier --write .",
"prepare": "husky install"
"prepare": "husky install",
"test": "jasmine-ts -r tsconfig-paths/register -P spec/tsconfig.json",
"test:watch": "nodemon -w ./spec -w ./src -w ./jslib --ext \"ts,js,mjs,json\" --exec jasmine-ts -r tsconfig-paths/register -P spec/tsconfig.json"
},
"bin": {
"bw": "build/bw.js"
@ -51,8 +53,10 @@
"assets": "./build/**/*"
},
"devDependencies": {
"@fluffy-spoon/substitute": "^1.208.0",
"@types/express": "^4.17.13",
"@types/inquirer": "^7.3.1",
"@types/jasmine": "^3.7.0",
"@types/jsdom": "^16.2.10",
"@types/lowdb": "^1.0.10",
"@types/lunr": "^2.3.3",
@ -67,11 +71,17 @@
"copy-webpack-plugin": "^10.2.0",
"cross-env": "^7.0.3",
"husky": "^7.0.4",
"jasmine": "^3.7.0",
"jasmine-core": "^3.7.1",
"jasmine-ts": "^0.4.0",
"jasmine-ts-console-reporter": "^3.1.1",
"lint-staged": "^12.1.3",
"pkg": "^5.5.1",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"ts-loader": "^8.2.0",
"ts-node": "^10.4.0",
"tsconfig-paths": "^3.12.0",
"tsconfig-paths-webpack-plugin": "^3.5.2",
"tslint": "^6.1.3",
"tslint-loader": "^3.5.4",

3
spec/bw.spec.ts Normal file
View File

@ -0,0 +1,3 @@
describe("bw", () => {
it("is a placeholder test");
});

4
spec/helpers.ts Normal file
View File

@ -0,0 +1,4 @@
// tslint:disable-next-line
const TSConsoleReporter = require("jasmine-ts-console-reporter");
jasmine.getEnv().clearReporters(); // Clear default console reporter
jasmine.getEnv().addReporter(new TSConsoleReporter());

View File

@ -0,0 +1,7 @@
{
"spec_dir": "spec",
"spec_files": ["**/*[sS]pec.ts"],
"helpers": ["helpers.ts"],
"stopSpecOnExpectationFailure": false,
"random": true
}

7
spec/tsconfig.json Normal file
View File

@ -0,0 +1,7 @@
{
"extends": "../tsconfig",
"include": ["src", "spec"],
"compilerOptions": {
"module": "commonjs"
}
}