polendina 3.3.2 → 3.3.3
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/.github/dependabot.yml +1 -130
- package/.github/workflows/test-and-release.yml +1 -3
- package/AGENTS.md +59 -39
- package/CHANGELOG.md +6 -0
- package/lib/webpack.config.js +5 -2
- package/package.json +3 -4
- package/test/common.js +27 -10
- package/test/consumer/package.json +11 -0
- package/test/fixtures/bare-async/package.json +1 -14
- package/test/fixtures/bare-async-esm/package.json +2 -15
- package/test/fixtures/bare-async-failure/package.json +1 -14
- package/test/fixtures/bare-async-failure-esm/package.json +2 -15
- package/test/fixtures/bare-sync/package.json +1 -14
- package/test/fixtures/bare-sync-esm/package.json +2 -15
- package/test/fixtures/bare-sync-failure/package.json +1 -14
- package/test/fixtures/bare-sync-failure-esm/package.json +2 -15
- package/test/fixtures/mocha/package.json +1 -15
- package/test/fixtures/mocha-esm/package.json +2 -16
- package/test/fixtures/mocha-failure/package.json +1 -15
- package/test/fixtures/mocha-failure-esm/package.json +2 -16
- package/test/fixtures/tape/package.json +1 -14
- package/test/fixtures/tape-esm/package.json +2 -15
- package/test/fixtures/tape-failure/package.json +1 -14
- package/test/fixtures/tape-failure-esm/package.json +2 -15
- package/test/fixtures/webpack-merge/package.json +1 -14
- package/test/setup.js +96 -0
- package/test/test-bare-async.js +10 -14
- package/test/test-bare-sync.js +10 -14
- package/test/test-mocha.js +23 -23
- package/test/test-packed-install.js +29 -69
- package/test/test-polendina-node.js +9 -19
- package/test/test-tape.js +10 -14
- package/test/test-webpack-merge.js +3 -7
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "mocha test-*.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1",
|
|
17
|
-
"mocha": "^12.0.2"
|
|
18
|
-
}
|
|
4
|
+
"private": true
|
|
19
5
|
}
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "mocha test-*.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1",
|
|
18
|
-
"mocha": "^12.0.2"
|
|
19
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
20
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "tape test.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"tape": "^5.6.3"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "tape test.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"tape": "^5.6.3"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "tape test.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"license": "Apache-2.0",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"tape": "^5.6.3"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-tape-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "tape test.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"license": "Apache-2.0",
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"tape": "^5.6.3"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-webpack-merge",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test.js"
|
|
8
|
-
},
|
|
9
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
13
|
-
},
|
|
14
|
-
"license": "Apache-2.0",
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"chai": "^6.0.1"
|
|
17
|
-
}
|
|
4
|
+
"private": true
|
|
18
5
|
}
|
package/test/setup.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Mocha global fixtures. Packs polendina and installs it into temporary
|
|
2
|
+
// consumer directories outside the repository, one per test runner, each with
|
|
3
|
+
// only the frameworks that runner's fixtures import at the versions in
|
|
4
|
+
// test/consumer/package.json, then copies test/fixtures in. npm hoists polendina's dependencies into each consumer's node_modules,
|
|
5
|
+
// the layout a real install has and one the fixtures cannot produce from
|
|
6
|
+
// inside this tree. Keeping the runners apart means no runner's dependency
|
|
7
|
+
// tree can shadow or nest another's.
|
|
8
|
+
//
|
|
9
|
+
// Tests find the consumers through POLENDINA_CONSUMERS, a JSON object of
|
|
10
|
+
// name to directory. Set POLENDINA_KEEP_CONSUMERS to leave them behind.
|
|
11
|
+
|
|
12
|
+
import fs from 'fs'
|
|
13
|
+
import os from 'os'
|
|
14
|
+
import path from 'path'
|
|
15
|
+
import { exec } from 'child_process'
|
|
16
|
+
import { fileURLToPath } from 'url'
|
|
17
|
+
|
|
18
|
+
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
19
|
+
const root = path.join(__dirname, '..')
|
|
20
|
+
const puppeteerVersion = JSON.parse(fs.readFileSync(path.join(root, 'node_modules/puppeteer/package.json'))).version
|
|
21
|
+
const template = JSON.parse(fs.readFileSync(path.join(__dirname, 'consumer/package.json'))).devDependencies
|
|
22
|
+
|
|
23
|
+
// consumer name to the packages it installs alongside polendina; a bare name
|
|
24
|
+
// takes its version range from test/consumer/package.json, name@range pins one
|
|
25
|
+
const variants = {
|
|
26
|
+
mocha: ['mocha', 'chai'],
|
|
27
|
+
mocha11: ['mocha@11', 'chai'],
|
|
28
|
+
tape: ['tape'],
|
|
29
|
+
bare: ['chai']
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const consumers = {}
|
|
33
|
+
|
|
34
|
+
function dependency (pkg) {
|
|
35
|
+
const at = pkg.indexOf('@', 1)
|
|
36
|
+
if (at > 0) {
|
|
37
|
+
return [pkg.slice(0, at), pkg.slice(at + 1)]
|
|
38
|
+
}
|
|
39
|
+
if (!template[pkg]) {
|
|
40
|
+
throw new Error(`${pkg} is not in test/consumer/package.json`)
|
|
41
|
+
}
|
|
42
|
+
return [pkg, template[pkg]]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function sh (command, cwd) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
const env = { ...process.env, PUPPETEER_SKIP_DOWNLOAD: '1' }
|
|
48
|
+
exec(command, { cwd, env }, (err, stdout, stderr) => {
|
|
49
|
+
if (err) {
|
|
50
|
+
return reject(new Error(`${command}\n${stderr}`))
|
|
51
|
+
}
|
|
52
|
+
resolve(stdout.toString())
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function installConsumer (name, tarball, packages) {
|
|
58
|
+
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), `polendina-consumer-${name}-`))
|
|
59
|
+
const pkg = {
|
|
60
|
+
name: `polendina-consumer-${name}`,
|
|
61
|
+
private: true,
|
|
62
|
+
devDependencies: {
|
|
63
|
+
polendina: `file:${tarball}`,
|
|
64
|
+
puppeteer: puppeteerVersion,
|
|
65
|
+
...Object.fromEntries(packages.map(dependency))
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
await fs.promises.writeFile(path.join(dir, 'package.json'), JSON.stringify(pkg, null, 2))
|
|
69
|
+
await fs.promises.cp(path.join(__dirname, 'fixtures'), path.join(dir, 'fixtures'), {
|
|
70
|
+
recursive: true,
|
|
71
|
+
filter: (src) => path.basename(src) !== 'node_modules'
|
|
72
|
+
})
|
|
73
|
+
await sh('npm install --no-audit --no-fund --no-package-lock --prefer-offline', dir)
|
|
74
|
+
return dir
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function mochaGlobalSetup () {
|
|
78
|
+
const packDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'polendina-pack-'))
|
|
79
|
+
const [{ filename }] = JSON.parse(await sh(`npm pack --json --pack-destination "${packDir}"`, root))
|
|
80
|
+
const tarball = path.join(packDir, filename)
|
|
81
|
+
await Promise.all(Object.entries(variants).map(async ([name, packages]) => {
|
|
82
|
+
consumers[name] = await installConsumer(name, tarball, packages)
|
|
83
|
+
}))
|
|
84
|
+
await fs.promises.rm(packDir, { recursive: true, force: true })
|
|
85
|
+
process.env.POLENDINA_CONSUMERS = JSON.stringify(consumers)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export async function mochaGlobalTeardown () {
|
|
89
|
+
if (process.env.POLENDINA_KEEP_CONSUMERS) {
|
|
90
|
+
console.log('Keeping consumers:', consumers)
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
for (const dir of Object.values(consumers)) {
|
|
94
|
+
await fs.promises.rm(dir, { recursive: true, force: true })
|
|
95
|
+
}
|
|
96
|
+
}
|
package/test/test-bare-async.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
3
|
import assert from 'assert'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
4
|
import { runCli } from './common.js'
|
|
7
5
|
|
|
8
|
-
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
|
-
|
|
10
6
|
for (const type of ['cjs', 'esm']) {
|
|
11
|
-
const bareAsyncFixture =
|
|
12
|
-
const bareAsyncFailureFixture =
|
|
7
|
+
const bareAsyncFixture = `bare-async${type === 'esm' ? '-esm' : ''}`
|
|
8
|
+
const bareAsyncFailureFixture = `bare-async-failure${type === 'esm' ? '-esm' : ''}`
|
|
13
9
|
|
|
14
10
|
describe(`basic bare-async (${type})`, function () {
|
|
15
11
|
this.timeout(60000)
|
|
@@ -27,7 +23,7 @@ testing bare fixture subdir
|
|
|
27
23
|
`
|
|
28
24
|
|
|
29
25
|
it('should run in page', async () => {
|
|
30
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async')
|
|
26
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async'])
|
|
31
27
|
if (code !== 0) {
|
|
32
28
|
console.error(stderr)
|
|
33
29
|
}
|
|
@@ -41,7 +37,7 @@ testing bare fixture subdir
|
|
|
41
37
|
})
|
|
42
38
|
|
|
43
39
|
it('should run in worker', async () => {
|
|
44
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --page=false')
|
|
40
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async', '--worker', '--page=false'])
|
|
45
41
|
if (code !== 0) {
|
|
46
42
|
console.error(stderr)
|
|
47
43
|
}
|
|
@@ -55,7 +51,7 @@ testing bare fixture subdir
|
|
|
55
51
|
})
|
|
56
52
|
|
|
57
53
|
it('should run in serviceworker', async () => {
|
|
58
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --serviceworker --page=false')
|
|
54
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async', '--serviceworker', '--page=false'])
|
|
59
55
|
if (code !== 0) {
|
|
60
56
|
console.error(stderr)
|
|
61
57
|
}
|
|
@@ -69,7 +65,7 @@ testing bare fixture subdir
|
|
|
69
65
|
})
|
|
70
66
|
|
|
71
67
|
it('should run in page, worker and serviceworker', async () => {
|
|
72
|
-
const { stdout, stderr, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --serviceworker')
|
|
68
|
+
const { stdout, stderr, code } = await runCli('bare', bareAsyncFixture, ['--runner=bare-async', '--worker', '--serviceworker'])
|
|
73
69
|
if (code !== 0) {
|
|
74
70
|
console.error(stderr)
|
|
75
71
|
}
|
|
@@ -111,7 +107,7 @@ testing bare fixture
|
|
|
111
107
|
const expectedStderr = 'AssertionError: faily mcfailface'
|
|
112
108
|
|
|
113
109
|
it('should fail in page', async () => {
|
|
114
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async')
|
|
110
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async'])
|
|
115
111
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
116
112
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
117
113
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -124,7 +120,7 @@ testing bare fixture
|
|
|
124
120
|
})
|
|
125
121
|
|
|
126
122
|
it('should fail in worker', async () => {
|
|
127
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --worker --page=false')
|
|
123
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async', '--worker', '--page=false'])
|
|
128
124
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
129
125
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
130
126
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -137,7 +133,7 @@ testing bare fixture
|
|
|
137
133
|
})
|
|
138
134
|
|
|
139
135
|
it('should fail in serviceworker', async () => {
|
|
140
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --serviceworker --page=false')
|
|
136
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async', '--serviceworker', '--page=false'])
|
|
141
137
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
142
138
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
143
139
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -150,7 +146,7 @@ testing bare fixture
|
|
|
150
146
|
})
|
|
151
147
|
|
|
152
148
|
it('should fail in page and not run in worker', async () => {
|
|
153
|
-
let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --worker')
|
|
149
|
+
let { stdout, stderr, code } = await runCli('bare', bareAsyncFailureFixture, ['--runner=bare-async', '--worker'])
|
|
154
150
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
155
151
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
156
152
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
package/test/test-bare-sync.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
3
|
import assert from 'assert'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
4
|
import { runCli } from './common.js'
|
|
7
5
|
|
|
8
|
-
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
|
-
|
|
10
6
|
for (const type of ['cjs', 'esm']) {
|
|
11
|
-
const bareSyncFixture =
|
|
12
|
-
const bareSyncFailureFixture =
|
|
7
|
+
const bareSyncFixture = `bare-sync${type === 'esm' ? '-esm' : ''}`
|
|
8
|
+
const bareSyncFailureFixture = `bare-sync-failure${type === 'esm' ? '-esm' : ''}`
|
|
13
9
|
|
|
14
10
|
describe(`basic bare-sync (${type})`, function () {
|
|
15
11
|
this.timeout(60000)
|
|
@@ -23,7 +19,7 @@ testing bare fixture subdir
|
|
|
23
19
|
`
|
|
24
20
|
|
|
25
21
|
it('should run in page', async () => {
|
|
26
|
-
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync')
|
|
22
|
+
const { stdout, stderr, code } = await runCli('bare', bareSyncFixture, ['--runner=bare-sync'])
|
|
27
23
|
if (code !== 0) {
|
|
28
24
|
console.error(stderr)
|
|
29
25
|
}
|
|
@@ -37,7 +33,7 @@ testing bare fixture subdir
|
|
|
37
33
|
})
|
|
38
34
|
|
|
39
35
|
it('should run in worker', async () => {
|
|
40
|
-
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --page=false')
|
|
36
|
+
const { stdout, stderr, code } = await runCli('bare', bareSyncFixture, ['--runner=bare-sync', '--worker', '--page=false'])
|
|
41
37
|
if (code !== 0) {
|
|
42
38
|
console.error(stderr)
|
|
43
39
|
}
|
|
@@ -51,7 +47,7 @@ testing bare fixture subdir
|
|
|
51
47
|
})
|
|
52
48
|
|
|
53
49
|
it('should run in serviceworker', async () => {
|
|
54
|
-
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync --serviceworker --page=false')
|
|
50
|
+
const { stdout, stderr, code } = await runCli('bare', bareSyncFixture, ['--runner=bare-sync', '--serviceworker', '--page=false'])
|
|
55
51
|
if (code !== 0) {
|
|
56
52
|
console.error(stderr)
|
|
57
53
|
}
|
|
@@ -65,7 +61,7 @@ testing bare fixture subdir
|
|
|
65
61
|
})
|
|
66
62
|
|
|
67
63
|
it('should run in page, worker and serviceworker', async () => {
|
|
68
|
-
const { stdout, stderr, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --serviceworker')
|
|
64
|
+
const { stdout, stderr, code } = await runCli('bare', bareSyncFixture, ['--runner=bare-sync', '--worker', '--serviceworker'])
|
|
69
65
|
if (code !== 0) {
|
|
70
66
|
console.error(stderr)
|
|
71
67
|
}
|
|
@@ -105,7 +101,7 @@ testing bare fixture
|
|
|
105
101
|
const expectedStderr = 'AssertionError: faily mcfailface'
|
|
106
102
|
|
|
107
103
|
it('should fail in page', async () => {
|
|
108
|
-
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync')
|
|
104
|
+
let { stdout, stderr, code } = await runCli('bare', bareSyncFailureFixture, ['--runner=bare-sync'])
|
|
109
105
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
110
106
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
111
107
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -118,7 +114,7 @@ testing bare fixture
|
|
|
118
114
|
})
|
|
119
115
|
|
|
120
116
|
it('should fail in worker', async () => {
|
|
121
|
-
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync --worker --page=false')
|
|
117
|
+
let { stdout, stderr, code } = await runCli('bare', bareSyncFailureFixture, ['--runner=bare-sync', '--worker', '--page=false'])
|
|
122
118
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
123
119
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
124
120
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -131,7 +127,7 @@ testing bare fixture
|
|
|
131
127
|
})
|
|
132
128
|
|
|
133
129
|
it('should fail in serviceworker', async () => {
|
|
134
|
-
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync --serviceworker --page=false')
|
|
130
|
+
let { stdout, stderr, code } = await runCli('bare', bareSyncFailureFixture, ['--runner=bare-sync', '--serviceworker', '--page=false'])
|
|
135
131
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
136
132
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
137
133
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -144,7 +140,7 @@ testing bare fixture
|
|
|
144
140
|
})
|
|
145
141
|
|
|
146
142
|
it('should fail in page and not run in worker', async () => {
|
|
147
|
-
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync --worker')
|
|
143
|
+
let { stdout, stderr, code } = await runCli('bare', bareSyncFailureFixture, ['--runner=bare-sync', '--worker'])
|
|
148
144
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
149
145
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
150
146
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
package/test/test-mocha.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
3
|
import assert from 'assert'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
4
|
import { runCli } from './common.js'
|
|
7
5
|
|
|
8
|
-
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
|
-
|
|
10
6
|
function removeTimings (stdout) {
|
|
11
7
|
return stdout.replace(/\(\d+ms\)/g, '(Xms)')
|
|
12
8
|
}
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
// the consumers to run against, with the spec reporter's pass symbol, which
|
|
11
|
+
// differs by major in the browser bundle
|
|
12
|
+
const ticks = { mocha: '\u2714', mocha11: '\u2705' }
|
|
13
|
+
|
|
14
|
+
for (const [consumerName, type] of Object.keys(ticks).flatMap((c) => ['cjs', 'esm'].map((t) => [c, t]))) {
|
|
15
|
+
const mochaFixture = `mocha${type === 'esm' ? '-esm' : ''}`
|
|
16
|
+
const mochaFailureFixture = `mocha-failure${type === 'esm' ? '-esm' : ''}`
|
|
17
17
|
|
|
18
|
-
describe(`basic mocha (${type})`, function () {
|
|
18
|
+
describe(`basic mocha (${type}, ${consumerName})`, function () {
|
|
19
19
|
this.timeout(60000)
|
|
20
20
|
const expectedTemplate = `
|
|
21
21
|
test suite 1
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
${ticks[consumerName]} test case 1
|
|
23
|
+
${ticks[consumerName]} test case 2
|
|
24
24
|
|
|
25
25
|
test suite 2 - worker
|
|
26
|
-
|
|
26
|
+
${ticks[consumerName]} is WORKER
|
|
27
27
|
|
|
28
28
|
test suite 3
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
${ticks[consumerName]} test case 1
|
|
30
|
+
${ticks[consumerName]} test case 2
|
|
31
31
|
`
|
|
32
32
|
|
|
33
33
|
it('should run in page', async () => {
|
|
34
|
-
const { stdout, stderr, code } = await runCli(mochaFixture)
|
|
34
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, [])
|
|
35
35
|
if (code !== 0) {
|
|
36
36
|
console.error(stderr)
|
|
37
37
|
}
|
|
@@ -45,7 +45,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
45
45
|
})
|
|
46
46
|
|
|
47
47
|
it('should run in worker', async () => {
|
|
48
|
-
const { stdout, stderr, code } = await runCli(mochaFixture, '--worker --page=false')
|
|
48
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, ['--worker', '--page=false'])
|
|
49
49
|
if (code !== 0) {
|
|
50
50
|
console.error(stderr)
|
|
51
51
|
}
|
|
@@ -59,7 +59,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('should run in serviceworker', async () => {
|
|
62
|
-
const { stdout, stderr, code } = await runCli(mochaFixture, '--serviceworker --page=false')
|
|
62
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, ['--serviceworker', '--page=false'])
|
|
63
63
|
if (code !== 0) {
|
|
64
64
|
console.error(stderr)
|
|
65
65
|
}
|
|
@@ -73,7 +73,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
it('should run in page, worker and serviceworker', async () => {
|
|
76
|
-
const { stdout, stderr, code } = await runCli(mochaFixture, '--worker --serviceworker')
|
|
76
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, ['--worker', '--serviceworker'])
|
|
77
77
|
if (code !== 0) {
|
|
78
78
|
console.error(stderr)
|
|
79
79
|
}
|
|
@@ -102,11 +102,11 @@ for (const type of ['cjs', 'esm']) {
|
|
|
102
102
|
})
|
|
103
103
|
})
|
|
104
104
|
|
|
105
|
-
describe(`failing mocha (${type})`, function () {
|
|
105
|
+
describe(`failing mocha (${type}, ${consumerName})`, function () {
|
|
106
106
|
this.timeout(60000)
|
|
107
107
|
const expectedTemplate = `
|
|
108
108
|
test suite 1 - worker
|
|
109
|
-
|
|
109
|
+
${ticks[consumerName]} is WORKER
|
|
110
110
|
|
|
111
111
|
test suite 2 - failing
|
|
112
112
|
1) should fail
|
|
@@ -121,7 +121,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
121
121
|
`
|
|
122
122
|
|
|
123
123
|
it('should fail in page', async () => {
|
|
124
|
-
let { stdout, code } = await runCli(mochaFailureFixture)
|
|
124
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, [])
|
|
125
125
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
126
126
|
stdout = removeTimings(stdout)
|
|
127
127
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -133,7 +133,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
133
133
|
})
|
|
134
134
|
|
|
135
135
|
it('should fail in worker', async () => {
|
|
136
|
-
let { stdout, code } = await runCli(mochaFailureFixture, '--worker --page=false')
|
|
136
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, ['--worker', '--page=false'])
|
|
137
137
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
138
138
|
stdout = removeTimings(stdout)
|
|
139
139
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -145,7 +145,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
145
145
|
})
|
|
146
146
|
|
|
147
147
|
it('should fail in serviceworker', async () => {
|
|
148
|
-
let { stdout, code } = await runCli(mochaFailureFixture, '--serviceworker --page=false')
|
|
148
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, ['--serviceworker', '--page=false'])
|
|
149
149
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
150
150
|
stdout = removeTimings(stdout)
|
|
151
151
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -157,7 +157,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
157
157
|
})
|
|
158
158
|
|
|
159
159
|
it('should fail in page and not run in worker', async () => {
|
|
160
|
-
let { stdout, code } = await runCli(mochaFailureFixture, '--worker')
|
|
160
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, ['--worker'])
|
|
161
161
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
162
162
|
stdout = removeTimings(stdout)
|
|
163
163
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|