@jcoreio/toolchain-mocha 3.4.1 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.mocharc.cjs CHANGED
@@ -1,17 +1,9 @@
1
1
  const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
2
2
  const extensions = getPluginsArraySync('sourceExtensions')
3
- const path = require('path')
4
-
5
- const files = process.argv.slice(2).filter((f) => {
6
- const ext = path.extname(f)
7
- return ext && extensions.includes(ext.substring(1))
8
- })
3
+ const getSpecs = require('./getSpecs.cjs')
9
4
 
10
5
  module.exports = {
11
6
  require: [require.resolve('./util/configureMocha.cjs')],
12
7
  reporter: 'spec',
13
- spec: [
14
- require.resolve('./util/mochaWatchClearConsole.cjs'),
15
- ...(files.length ? files : getPluginsArraySync('mochaSpecs')),
16
- ],
8
+ spec: getSpecs(getPluginsArraySync('mochaSpecs')),
17
9
  }
package/cliSpecs.cjs ADDED
@@ -0,0 +1,42 @@
1
+ const valuedOptions = new Set([
2
+ '--global',
3
+ '--globals',
4
+ '-j',
5
+ '--jobs',
6
+ '--retries',
7
+ '-s',
8
+ '--slow',
9
+ '-t',
10
+ '--timeout',
11
+ '--timeouts',
12
+ '-u',
13
+ '--ui',
14
+ '-R',
15
+ '--reporter',
16
+ '-O',
17
+ '--reporter-option',
18
+ '--reporter-options',
19
+ '--config',
20
+ '-n',
21
+ '--no-options',
22
+ '--package',
23
+ '--extension',
24
+ '--file',
25
+ '--ignore',
26
+ '--exclude',
27
+ '-r',
28
+ '--require',
29
+ '--watch-files',
30
+ '--watch-ignore',
31
+ '-f',
32
+ '--fgrep',
33
+ '-g',
34
+ '--grep',
35
+ ])
36
+
37
+ module.exports = process.argv
38
+ .slice(2)
39
+ .filter(
40
+ (f, index, argv) =>
41
+ !f.startsWith('-') && !valuedOptions.has(argv[index - 1])
42
+ )
package/getSpecs.cjs ADDED
@@ -0,0 +1,8 @@
1
+ const cliSpecs = require('./cliSpecs.cjs')
2
+
3
+ module.exports = function getSpecs(defaultSpecs) {
4
+ return [
5
+ require.resolve('./util/mochaWatchClearConsole.cjs'),
6
+ ...(cliSpecs.length ? cliSpecs : defaultSpecs),
7
+ ]
8
+ }
package/index.cjs ADDED
@@ -0,0 +1 @@
1
+ exports.getSpecs = require('./getSpecs.cjs')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain-mocha",
3
- "version": "3.4.1",
3
+ "version": "3.6.0",
4
4
  "description": "Mocha build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,15 +17,16 @@
17
17
  "mocha": "./bin/mocha",
18
18
  "nyc": "./bin/nyc"
19
19
  },
20
+ "main": "./index.cjs",
20
21
  "dependencies": {
21
22
  "dedent-js": "^1.0.1",
22
23
  "mocha": "^10.2.0",
23
24
  "nyc": "^15.1.0",
24
25
  "resolve-bin": "^1.0.0",
25
- "@jcoreio/toolchain": "3.4.1"
26
+ "@jcoreio/toolchain": "3.6.0"
26
27
  },
27
28
  "peerDependencies": {
28
- "@jcoreio/toolchain": "3.4.1"
29
+ "@jcoreio/toolchain": "3.6.0"
29
30
  },
30
31
  "toolchainManaged": {
31
32
  "devDependencies": {
@@ -1,17 +1,45 @@
1
1
  const execa = require('@jcoreio/toolchain/util/execa.cjs')
2
+ const { toolchainConfig } = require('@jcoreio/toolchain/util/findUps.cjs')
3
+
4
+ const testScripts = Object.entries(toolchainConfig.scripts || {}).filter(
5
+ ([name]) => /^test\W/.test(name)
6
+ )
2
7
 
3
8
  module.exports = [
4
9
  {
5
10
  coverage: {
6
- description: 'run tests with code coverage',
11
+ description: `run ${
12
+ testScripts.length ? 'all tests' : 'tests'
13
+ } with code coverage`,
7
14
  run: async (args = []) => {
8
15
  await execa('nyc', ['tc', 'test', ...args])
9
16
  },
10
17
  },
18
+ ...Object.fromEntries(
19
+ testScripts.map(([name, value]) => [
20
+ `coverage${name.substring(4)}`,
21
+ {
22
+ description: `${
23
+ typeof value.description === 'string'
24
+ ? value.description
25
+ : `run ${name}`
26
+ } with code coverage`,
27
+ run: async (args = []) => {
28
+ await execa('nyc', ['tc', name, ...args])
29
+ },
30
+ },
31
+ ])
32
+ ),
11
33
  test: {
12
- description: 'run tests',
34
+ description: `run ${testScripts.length ? 'all tests' : 'tests'}`,
13
35
  run: async (args = []) => {
14
- await execa('mocha', [...args])
36
+ if (testScripts.length) {
37
+ for (const [name] of testScripts) {
38
+ await execa('tc', [name, ...args])
39
+ }
40
+ } else {
41
+ await execa('mocha', [...args])
42
+ }
15
43
  },
16
44
  },
17
45
  },