diff --git a/README.md b/README.md index 92abc78..0a3be05 100644 --- a/README.md +++ b/README.md @@ -190,15 +190,15 @@ assertion syntax. The default configuration will recognize any file as a test file that... -- has a `.test.*js*` extension (i.e. `.test.cjs`, `.test.js`, `.test.mjs`, or - `.test.ts`). -- is not located in `node_modules`. +- has `.test.` just before its file name extension (i.e. `example.test.js`). +- is not located in the `node_modules` or `lib` directories. The sample code packages tests next to the source code they exercise. If you prefer to segregate your tests into a directory outside [`src`](./src/) (e.g. `test`), that will work as well. -Either way, all test files will be excluded from the build. +Either way, all test files meeting the above conditions will be excluded from +the build. To enable `mocha`-specific linting in your test files, add the following directive at the top of every test file: diff --git a/build.config.js b/build.config.js new file mode 100644 index 0000000..a15acdf --- /dev/null +++ b/build.config.js @@ -0,0 +1,6 @@ +const config = require('./babel.config'); + +module.exports = (api) => ({ + ...config(api), + ignore: [/\.test\.\w+$/], +}); diff --git a/package.json b/package.json index 904807b..2221828 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "require": [ "@babel/register" ], - "spec": "**/*.test.*js*" + "spec": "**/*.test.!(*.*)" }, "release-it": { "github": { @@ -71,7 +71,7 @@ } }, "scripts": { - "build": "rimraf ./lib && babel src -d lib --ignore **/*.test.cjs,**/*.test.js,**/*.test.mjs,**/*.test.ts", + "build": "rimraf ./lib && babel src -d lib --config-file ./build.config.js", "release": "dotenv -c -- release-it", "test": "mocha" }