Skip to content

Commit

Permalink
Mocha CLI Args (#63)
Browse files Browse the repository at this point in the history
* Implement Mocha-specific args parser

* Configure new parseArgv to split Webpack and Mochapack args in output

* Add function for converting Mocha args to options

* Ensure options from parsed args handles Webpack and Mochapack args

* Refactor requireWebpackConfig to make it easier to reason about

* Rename parseConfig to parseMochaOptsFile to be more explicit

* Improve arg translation to simplify Mocha init, rename loadReporter to getReporterConstructor to increase explicitness

* Add a new Mocha initializer function and clean up eslint in tests

* Split webpack config creation into separate method and improve readability

* Whoops missed that glob was an internal util instead of from external library

* Fix broken tests after glob replacement

* Convert loose strings to constants

* Begin shifting MochaWebpack constructor to prefer configuration at initialization

* Rework library to use new args parser and Mocha initializer

* Clean up and light directory structure refactor

* Rename MochaWebpack to Mochapack

* Drop Mocha 4 support

* Loosen equality strictness for initMocha test

* Ensure tests run with Mocha 6 and 7

* Update Mocha peer dependency version

* Update ts-mocha to fix mocha peer dependency issue

* Fix major version checking
  • Loading branch information
Jack Alden Barry authored May 6, 2020
1 parent ff12edd commit 3fae494
Show file tree
Hide file tree
Showing 82 changed files with 5,395 additions and 4,572 deletions.
14 changes: 13 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"error",
{ "peerDependencies": true }
],
"import/prefer-default-export": "off",
"no-duplicate-imports": "off",
"no-restricted-syntax": "off",
"no-unused-vars": "off"
Expand All @@ -31,5 +32,16 @@
"extensions": [".js", ".ts"]
}
}
}
},
"overrides": [
{
"files": ["**/*.test.**"],
"env": {
"mocha": true
},
"rules": {
"no-unused-expressions": "off"
}
}
]
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
**/*.txt
**/*.css
**/*.scss
**/*.yml
test/**/*.js
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ install:
- yarn install --immutable

env:
- WEBPACK_VERSION=4 MOCHA_VERSION=4
- WEBPACK_VERSION=4 MOCHA_VERSION=5
- WEBPACK_VERSION=4 MOCHA_VERSION=6
- WEBPACK_VERSION=4 MOCHA_VERSION=7

Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"description": "mocha cli with webpack support",
"bin": "./bin/mochapack",
"main": "./lib/createMochaWebpack.js",
"main": "./lib/createMochapack.js",
"files": [
"*.md",
"bin",
Expand All @@ -21,7 +21,7 @@
"build": "yarn run clean-lib && tsc",
"format": "prettier '{src,test}/**/*' ./*.json --write --loglevel warn",
"lint": "eslint src/**/*.ts test/**/*.ts --fix",
"test": "yarn run clean-tmp && yarn run build && ts-mocha --timeout 10000 --recursive --require @babel/register --exit \"test/**/*.test.ts\"",
"test": "yarn run clean-tmp && yarn run build && ts-mocha --timeout 10000 --recursive --require @babel/register --exit \"{test,src}/**/*.test.ts\"",
"cover": "cross-env BABEL_ENV=coverage nyc --reporter=lcov --reporter=text npm test",
"posttest": "yarn run format && yarn run lint",
"docs:clean": "del-cli _book",
Expand All @@ -48,7 +48,7 @@
"author": "Victor Vlasenko <[email protected]>",
"license": "MIT",
"peerDependencies": {
"mocha": ">=4 <=7",
"mocha": ">=6 <=7",
"webpack": "^4.0.0"
},
"devDependencies": {
Expand All @@ -66,7 +66,10 @@
"@types/lodash": "^4.14.149",
"@types/mocha": "^5.2.7",
"@types/node": "^12.12.17",
"@types/sinon": "^9.0.0",
"@types/sinon-chai": "^3.2.4",
"@types/webpack": "^4.41.0",
"@types/yargs": "^15.0.4",
"@typescript-eslint/eslint-plugin": "^2.11.0",
"@typescript-eslint/parser": "^2.11.0",
"anymatch": "3.1.1",
Expand Down Expand Up @@ -99,11 +102,12 @@
"nyc": "14.1.1",
"prettier": "^1.19.1",
"sass-loader": "6.0.7",
"sinon": "7.5.0",
"sinon": "^9.0.2",
"sinon-chai": "^3.5.0",
"strip-ansi": "^5.2.0",
"tiny-worker": "2.3.0",
"ts-mocha": "^6.0.0",
"typescript": "^3.7.3",
"ts-mocha": "^7.0.0",
"typescript": "^3.8.3",
"webpack": "4.41.0",
"worker-loader": "2.0.0",
"write-file-webpack-plugin": "^4.2.0"
Expand Down
Loading

0 comments on commit 3fae494

Please sign in to comment.