@jcoreio/toolchain-mocha 3.6.3 → 3.8.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
@@ -6,4 +6,12 @@ module.exports = {
6
6
  require: [require.resolve('./util/configureMocha.cjs')],
7
7
  reporter: 'spec',
8
8
  spec: getSpecs(getPluginsArraySync('mochaSpecs')),
9
+ ...(process.env.JCOREIO_TOOLCHAIN_ESM
10
+ ? {
11
+ 'node-option': [
12
+ 'experimental-default-type=module',
13
+ `import=@jcoreio/toolchain-esnext/util/esmLoader.cjs`,
14
+ ],
15
+ }
16
+ : {}),
9
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcoreio/toolchain-mocha",
3
- "version": "3.6.3",
3
+ "version": "3.8.0",
4
4
  "description": "Mocha build toolchain",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,10 +24,10 @@
24
24
  "mocha": "^10.2.0",
25
25
  "nyc": "^15.1.0",
26
26
  "resolve-bin": "^1.0.0",
27
- "@jcoreio/toolchain": "3.6.3"
27
+ "@jcoreio/toolchain": "3.8.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@jcoreio/toolchain": "3.6.3"
30
+ "@jcoreio/toolchain": "3.8.0"
31
31
  },
32
32
  "toolchainManaged": {
33
33
  "devDependencies": {
@@ -1,56 +1,88 @@
1
1
  const execa = require('@jcoreio/toolchain/util/execa.cjs')
2
- const { toolchainConfig } = require('@jcoreio/toolchain/util/findUps.cjs')
2
+ const {
3
+ toolchainPackages,
4
+ toolchainConfig,
5
+ } = require('@jcoreio/toolchain/util/findUps.cjs')
3
6
 
4
7
  const testScripts = Object.entries(toolchainConfig.scripts || {}).filter(
5
8
  ([name]) => /^test\W/.test(name)
6
9
  )
7
10
 
8
- module.exports = [
9
- {
10
- coverage: {
11
- description: `run ${
12
- testScripts.length ? 'all tests' : 'tests'
13
- } with code coverage`,
14
- run: async (args = []) => {
15
- await execa('nyc', ['tc', 'test', ...args], {
16
- env: {
17
- ...process.env,
18
- JCOREIO_TOOLCHAIN_COVERAGE: '1',
19
- },
20
- })
21
- },
11
+ const makeScripts = ({
12
+ suffix = '',
13
+ env = process.env,
14
+ descriptionSuffix = '',
15
+ } = {}) => ({
16
+ [`coverage${suffix}`]: {
17
+ description: `run all tests${descriptionSuffix} with code coverage`,
18
+ run: async (args = []) => {
19
+ await execa('nyc', ['tc', `test${suffix}`, ...args], {
20
+ env: {
21
+ ...env,
22
+ JCOREIO_TOOLCHAIN_COVERAGE: '1',
23
+ },
24
+ })
22
25
  },
23
- ...Object.fromEntries(
24
- testScripts.map(([name, value]) => [
25
- `coverage${name.substring(4)}`,
26
- {
27
- description: `${
28
- typeof value.description === 'string'
29
- ? value.description
30
- : `run ${name}`
31
- } with code coverage`,
32
- run: async (args = []) => {
33
- await execa('nyc', ['tc', name, ...args], {
34
- env: {
35
- ...process.env,
36
- JCOREIO_TOOLCHAIN_COVERAGE: '1',
37
- },
38
- })
39
- },
26
+ },
27
+ ...Object.fromEntries(
28
+ testScripts.map(([name, value]) => [
29
+ `coverage${name.substring(4)}${suffix}`,
30
+ {
31
+ description: `${
32
+ typeof value.description === 'string'
33
+ ? value.description
34
+ : `run ${name}`
35
+ }${descriptionSuffix} with code coverage`,
36
+ run: async (args = []) => {
37
+ await execa('nyc', ['tc', name, ...args], {
38
+ env: {
39
+ ...env,
40
+ JCOREIO_TOOLCHAIN_COVERAGE: '1',
41
+ },
42
+ })
40
43
  },
41
- ])
42
- ),
43
- test: {
44
- description: `run ${testScripts.length ? 'all tests' : 'tests'}`,
45
- run: async (args = []) => {
46
- if (testScripts.length) {
47
- for (const [name] of testScripts) {
48
- await execa('tc', [name, ...args])
49
- }
50
- } else {
51
- await execa('mocha', [...args])
52
- }
53
44
  },
45
+ ])
46
+ ),
47
+ [`test${suffix}`]: {
48
+ description: `run all tests${descriptionSuffix}`,
49
+ run: async (args = []) => {
50
+ if (testScripts.length) {
51
+ for (const [name] of testScripts) {
52
+ await execa('tc', [name, ...args], { env })
53
+ }
54
+ } else {
55
+ await execa('mocha', [...args], { env })
56
+ }
54
57
  },
55
58
  },
56
- ]
59
+ })
60
+
61
+ module.exports = [makeScripts()]
62
+
63
+ if (
64
+ toolchainConfig.outputEsm !== false &&
65
+ toolchainPackages.includes('@jcoreio/toolchain-esnext')
66
+ ) {
67
+ module.exports = [
68
+ {
69
+ ...makeScripts({
70
+ descriptionSuffix: ' in CJS mode',
71
+ env: {
72
+ ...process.env,
73
+ JCOREIO_TOOLCHAIN_TEST: '1',
74
+ JCOREIO_TOOLCHAIN_CJS: '1',
75
+ },
76
+ }),
77
+ ...makeScripts({
78
+ suffix: ':esm',
79
+ descriptionSuffix: ' in ESM mode',
80
+ env: {
81
+ ...process.env,
82
+ JCOREIO_TOOLCHAIN_TEST: '1',
83
+ JCOREIO_TOOLCHAIN_ESM: '1',
84
+ },
85
+ }),
86
+ },
87
+ ]
88
+ }
@@ -0,0 +1,12 @@
1
+ module.exports = [
2
+ () => [
3
+ {
4
+ name: 'test:debug <file>',
5
+ port: 9229,
6
+ request: 'attach',
7
+ skipFiles: ['<node_internals>/**'],
8
+ type: 'node',
9
+ preLaunchTask: 'test:debug <file>',
10
+ },
11
+ ],
12
+ ]
@@ -0,0 +1,31 @@
1
+ const common = {
2
+ type: 'shell',
3
+ options: { shell: { executable: 'bash', args: ['-c', '-l'] } },
4
+ command: 'pnpm',
5
+ isBackground: false,
6
+ group: 'test',
7
+ presentation: {
8
+ panel: 'dedicated',
9
+ clear: true,
10
+ },
11
+ }
12
+
13
+ module.exports = [
14
+ () => [
15
+ {
16
+ ...common,
17
+ label: 'test <file>',
18
+ args: ['tc', 'test', '${file}'],
19
+ },
20
+ {
21
+ ...common,
22
+ label: 'test:watch <file>',
23
+ args: ['tc', 'test', '--watch', '${file}'],
24
+ },
25
+ {
26
+ ...common,
27
+ label: 'test:debug <file>',
28
+ args: ['tc', 'test', '-n', 'inspect-brk', '${file}'],
29
+ },
30
+ ],
31
+ ]