@jcoreio/toolchain-mocha 3.6.2 → 3.7.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 +8 -0
- package/nyc.config.cjs +3 -2
- package/package.json +4 -3
- package/plugins/babelPlugins.cjs +19 -0
- package/plugins/scripts.cjs +77 -35
- package/plugins/vscodeLaunch.cjs +12 -0
- package/plugins/vscodeTasks.cjs +31 -0
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/nyc.config.cjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
const { toolchainPackages } = require('@jcoreio/toolchain/util/findUps.cjs')
|
|
1
2
|
const getPluginsArraySync = require('@jcoreio/toolchain/util/getPluginsArraySync.cjs')
|
|
2
3
|
|
|
3
4
|
module.exports = {
|
|
4
5
|
include: ['src/**'],
|
|
5
6
|
extension: getPluginsArraySync('sourceExtensions').map((ext) => '.' + ext),
|
|
6
7
|
reporter: ['lcov', 'text'],
|
|
7
|
-
sourceMap:
|
|
8
|
-
instrument:
|
|
8
|
+
sourceMap: !toolchainPackages.includes('@jcoreio/toolchain-esnext'),
|
|
9
|
+
instrument: !toolchainPackages.includes('@jcoreio/toolchain-esnext'),
|
|
9
10
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcoreio/toolchain-mocha",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.0",
|
|
4
4
|
"description": "Mocha build toolchain",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,14 +19,15 @@
|
|
|
19
19
|
},
|
|
20
20
|
"main": "./index.cjs",
|
|
21
21
|
"dependencies": {
|
|
22
|
+
"babel-plugin-istanbul": "^6.1.1",
|
|
22
23
|
"dedent-js": "^1.0.1",
|
|
23
24
|
"mocha": "^10.2.0",
|
|
24
25
|
"nyc": "^15.1.0",
|
|
25
26
|
"resolve-bin": "^1.0.0",
|
|
26
|
-
"@jcoreio/toolchain": "3.
|
|
27
|
+
"@jcoreio/toolchain": "3.7.0"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
|
-
"@jcoreio/toolchain": "3.
|
|
30
|
+
"@jcoreio/toolchain": "3.7.0"
|
|
30
31
|
},
|
|
31
32
|
"toolchainManaged": {
|
|
32
33
|
"devDependencies": {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module.exports = [
|
|
2
|
+
[
|
|
3
|
+
(api) => {
|
|
4
|
+
const { JCOREIO_TOOLCHAIN_COVERAGE } = process.env
|
|
5
|
+
api.cache.using(() => JCOREIO_TOOLCHAIN_COVERAGE)
|
|
6
|
+
return [
|
|
7
|
+
JCOREIO_TOOLCHAIN_COVERAGE && require.resolve('babel-plugin-istanbul'),
|
|
8
|
+
].filter(Boolean)
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
after: [
|
|
12
|
+
'@jcoreio/toolchain-esnext',
|
|
13
|
+
'@jcoreio/toolchain-flow',
|
|
14
|
+
'@jcoreio/toolchain-typescript',
|
|
15
|
+
'@jcoreio/toolchain-react',
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
]
|
package/plugins/scripts.cjs
CHANGED
|
@@ -1,46 +1,88 @@
|
|
|
1
1
|
const execa = require('@jcoreio/toolchain/util/execa.cjs')
|
|
2
|
-
const {
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
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
|
+
})
|
|
17
25
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
+
})
|
|
30
43
|
},
|
|
31
|
-
])
|
|
32
|
-
),
|
|
33
|
-
test: {
|
|
34
|
-
description: `run ${testScripts.length ? 'all tests' : 'tests'}`,
|
|
35
|
-
run: async (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
|
-
}
|
|
43
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
|
+
}
|
|
44
57
|
},
|
|
45
58
|
},
|
|
46
|
-
|
|
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,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
|
+
]
|