polendina 1.0.0 → 2.0.0-alpha
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 +154 -0
- package/.github/workflows/test-and-release.yml +61 -0
- package/lib/log.js +8 -8
- package/lib/puppeteer.js +6 -5
- package/lib/webpack.config.js +15 -18
- package/lib/{wrap-loader.js → wrap-loader.cjs} +10 -7
- package/package.json +99 -18
- package/polendina-cli.js +7 -6
- package/polendina-node-cli.js +10 -6
- package/polendina.js +45 -19
- package/resources/bare-run.js +3 -3
- package/resources/bare.js +7 -5
- package/resources/common-run.js +23 -26
- package/resources/mocha-run.js +12 -12
- package/resources/tape-run.js +5 -5
- package/resources/test-registry.js +4 -1
- package/test/common.js +8 -8
- package/test/fixtures/bare-async/package.json +4 -1
- package/test/fixtures/bare-async/test-1.js +1 -1
- package/test/fixtures/bare-async/test-2.js +1 -1
- package/test/fixtures/bare-async-esm/index.js +3 -0
- package/test/fixtures/bare-async-esm/package.json +19 -0
- package/test/fixtures/bare-async-esm/test-1.js +16 -0
- package/test/fixtures/bare-async-esm/test-2.js +11 -0
- package/test/fixtures/bare-async-failure/package.json +4 -1
- package/test/fixtures/bare-async-failure/test-1.js +1 -1
- package/test/fixtures/bare-async-failure/test-2.js +2 -2
- package/test/fixtures/bare-async-failure-esm/index.js +3 -0
- package/test/fixtures/bare-async-failure-esm/package.json +19 -0
- package/test/fixtures/bare-async-failure-esm/test-1.js +16 -0
- package/test/fixtures/bare-async-failure-esm/test-2.js +11 -0
- package/test/fixtures/bare-sync/package.json +4 -1
- package/test/fixtures/bare-sync/test-1.js +1 -1
- package/test/fixtures/bare-sync/test-2.js +2 -1
- package/test/fixtures/bare-sync-esm/index.js +1 -0
- package/test/fixtures/bare-sync-esm/package.json +19 -0
- package/test/fixtures/bare-sync-esm/test-1.js +14 -0
- package/test/fixtures/bare-sync-esm/test-2.js +7 -0
- package/test/fixtures/bare-sync-failure/package.json +4 -1
- package/test/fixtures/bare-sync-failure/test-1.js +1 -1
- package/test/fixtures/bare-sync-failure/test-2.js +2 -2
- package/test/fixtures/bare-sync-failure-esm/index.js +1 -0
- package/test/fixtures/bare-sync-failure-esm/package.json +19 -0
- package/test/fixtures/bare-sync-failure-esm/test-1.js +14 -0
- package/test/fixtures/bare-sync-failure-esm/test-2.js +6 -0
- package/test/fixtures/mocha/package.json +2 -1
- package/test/fixtures/mocha/test-1.js +1 -1
- package/test/fixtures/mocha/test-2.js +1 -1
- package/test/fixtures/mocha/test-3.js +1 -1
- package/test/fixtures/mocha-esm/index.js +1 -0
- package/test/fixtures/mocha-esm/package.json +20 -0
- package/test/fixtures/mocha-esm/test-1.js +14 -0
- package/test/fixtures/mocha-esm/test-2.js +19 -0
- package/test/fixtures/mocha-esm/test-3.js +14 -0
- package/test/fixtures/mocha-failure/package.json +2 -1
- package/test/fixtures/mocha-failure/test.js +1 -1
- package/test/fixtures/mocha-failure-esm/package.json +20 -0
- package/test/fixtures/mocha-failure-esm/test.js +24 -0
- package/test/fixtures/tape/package.json +1 -1
- package/test/fixtures/tape-esm/index.js +1 -0
- package/test/fixtures/tape-esm/package.json +19 -0
- package/test/fixtures/tape-esm/test.js +47 -0
- package/test/fixtures/tape-failure/package.json +1 -1
- package/test/fixtures/tape-failure-esm/package.json +19 -0
- package/test/fixtures/tape-failure-esm/test.js +29 -0
- package/test/fixtures/webpack-merge/package.json +4 -1
- package/test/fixtures/webpack-merge/test.js +3 -4
- package/test/fixtures/webpack-merge/webpack.config.js +3 -3
- package/test/test-bare-async.js +92 -87
- package/test/test-bare-sync.js +92 -87
- package/test/test-mocha.js +101 -96
- package/test/test-polendina-node.js +44 -38
- package/test/test-tape.js +99 -94
- package/test/test-webpack-merge.js +11 -9
- package/.github/workflows/main.yml +0 -21
package/test/test-bare-sync.js
CHANGED
|
@@ -1,114 +1,119 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import assert from 'assert'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import { runCli } from './common.js'
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
const bareSyncFailureFixture = path.join(__dirname, 'fixtures/bare-sync-failure')
|
|
8
|
+
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
10
|
+
for (const type of ['cjs', 'esm']) {
|
|
11
|
+
const bareSyncFixture = path.join(__dirname, `fixtures/bare-sync${type === 'esm' ? '-esm' : ''}`)
|
|
12
|
+
const bareSyncFailureFixture = path.join(__dirname, `fixtures/bare-sync-failure${type === 'esm' ? '-esm' : ''}`)
|
|
13
|
+
|
|
14
|
+
describe(`basic bare-sync (${type})`, function () {
|
|
15
|
+
this.timeout(20000)
|
|
16
|
+
const expectedTemplate = `
|
|
13
17
|
testing is WORKER
|
|
14
18
|
✔ test-1.js
|
|
15
19
|
testing bare fixture
|
|
16
20
|
✔ test-2.js
|
|
17
21
|
`
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
it('should run in page', async () => {
|
|
24
|
+
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync')
|
|
25
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
26
|
+
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
27
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
28
|
+
assert.ok(stdout.includes('Running bare-sync page tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
29
|
+
})
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
it('should run in worker', async () => {
|
|
32
|
+
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --page=false')
|
|
33
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
34
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
35
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
36
|
+
assert.ok(stdout.includes('Running bare-sync worker tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
37
|
+
})
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
it('should run in serviceworker', async () => {
|
|
40
|
+
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync --serviceworker --page=false')
|
|
41
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
42
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
43
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
44
|
+
assert.ok(stdout.includes('Running bare-sync serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
45
|
+
})
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
it('should run in page, worker and serviceworker', async () => {
|
|
48
|
+
const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-sync --worker --serviceworker')
|
|
49
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
52
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
53
|
+
assert.ok(stdout.includes('Running bare-sync serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
56
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
57
|
+
assert.ok(stdout.includes('Running bare-sync serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
60
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
61
|
+
assert.ok(stdout.includes('Running bare-sync serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
62
|
+
})
|
|
58
63
|
})
|
|
59
|
-
})
|
|
60
64
|
|
|
61
|
-
describe(
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
describe(`failing bare-sync (${type})`, function () {
|
|
66
|
+
this.timeout(20000)
|
|
67
|
+
const expectedTemplate = `
|
|
64
68
|
testing is WORKER
|
|
65
69
|
✔ test-1.js
|
|
66
70
|
testing bare fixture
|
|
67
71
|
✘ test-2.js
|
|
68
72
|
`
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
it('should fail in page', async () => {
|
|
72
|
-
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync')
|
|
73
|
-
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
74
|
-
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
75
|
-
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
76
|
-
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
77
|
-
assert.ok(stdout.includes('Running bare-sync page tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
78
|
-
assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
|
|
79
|
-
})
|
|
73
|
+
const expectedStderr = 'AssertionError: faily mcfailface'
|
|
80
74
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
it('should fail in page', async () => {
|
|
76
|
+
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync')
|
|
77
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
78
|
+
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
79
|
+
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
80
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
81
|
+
assert.ok(stdout.includes('Running bare-sync page tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
82
|
+
assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
|
|
83
|
+
})
|
|
90
84
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
it('should fail in worker', async () => {
|
|
86
|
+
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync --worker --page=false')
|
|
87
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
88
|
+
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
89
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
90
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
91
|
+
assert.ok(stdout.includes('Running bare-sync worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
92
|
+
assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('should fail in serviceworker', async () => {
|
|
96
|
+
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync --serviceworker --page=false')
|
|
97
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
98
|
+
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
99
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
100
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
101
|
+
assert.ok(stdout.includes('Running bare-sync serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
102
|
+
assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
|
|
103
|
+
})
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
105
|
+
it('should fail in page and not run in worker', async () => {
|
|
106
|
+
let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-sync --worker')
|
|
107
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
108
|
+
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
109
|
+
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
110
|
+
let found = stdout.indexOf(expected)
|
|
111
|
+
assert.ok(found > -1, 'stdout contains expected test output')
|
|
112
|
+
found = stdout.indexOf(expected, found + 1)
|
|
113
|
+
assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
|
|
114
|
+
assert.ok(stdout.includes('Running bare-sync page tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
115
|
+
assert.ok(!stdout.includes('Running bare-sync worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
|
|
116
|
+
assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
|
|
117
|
+
})
|
|
113
118
|
})
|
|
114
|
-
}
|
|
119
|
+
}
|
package/test/test-mocha.js
CHANGED
|
@@ -1,78 +1,82 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import assert from 'assert'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import { runCli } from './common.js'
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
-
const mochaFailureFixture = path.join(__dirname, 'fixtures/mocha-failure')
|
|
8
|
+
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
9
|
|
|
10
10
|
function removeTimings (stdout) {
|
|
11
11
|
return stdout.replace(/\(\d+ms\)/g, '(Xms)')
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
14
|
+
for (const type of ['cjs', 'esm']) {
|
|
15
|
+
const mochaFixture = path.join(__dirname, `fixtures/mocha${type === 'esm' ? '-esm' : ''}`)
|
|
16
|
+
const mochaFailureFixture = path.join(__dirname, `fixtures/mocha-failure${type === 'esm' ? '-esm' : ''}`)
|
|
17
|
+
|
|
18
|
+
describe(`basic mocha (${type})`, function () {
|
|
19
|
+
this.timeout(20000)
|
|
20
|
+
const expectedTemplate = `
|
|
17
21
|
test suite 1
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
✅ test case 1
|
|
23
|
+
✅ test case 2
|
|
20
24
|
|
|
21
25
|
test suite 2 - worker
|
|
22
|
-
|
|
26
|
+
✅ is WORKER
|
|
23
27
|
|
|
24
28
|
test suite 3
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
✅ test case 1
|
|
30
|
+
✅ test case 2
|
|
27
31
|
`
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
it('should run in page', async () => {
|
|
34
|
+
const { stdout, code } = await runCli(mochaFixture)
|
|
35
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
36
|
+
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
37
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
38
|
+
assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('should run in worker', async () => {
|
|
42
|
+
const { stdout, code } = await runCli(mochaFixture, '--worker --page=false')
|
|
43
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
44
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
45
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
46
|
+
assert.ok(stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should run in serviceworker', async () => {
|
|
50
|
+
const { stdout, code } = await runCli(mochaFixture, '--serviceworker --page=false')
|
|
51
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
52
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
53
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
54
|
+
assert.ok(stdout.includes('Running mocha serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should run in page, worker and serviceworker', async () => {
|
|
58
|
+
const { stdout, code } = await runCli(mochaFixture, '--worker --serviceworker')
|
|
59
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
60
|
+
|
|
61
|
+
let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
62
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
63
|
+
assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
64
|
+
|
|
65
|
+
expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
66
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
67
|
+
assert.ok(stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
68
|
+
|
|
69
|
+
expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
70
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
71
|
+
assert.ok(stdout.includes('Running mocha serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
72
|
+
})
|
|
51
73
|
})
|
|
52
74
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
58
|
-
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
59
|
-
assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
60
|
-
|
|
61
|
-
expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
62
|
-
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
63
|
-
assert.ok(stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
64
|
-
|
|
65
|
-
expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
66
|
-
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
67
|
-
assert.ok(stdout.includes('Running mocha serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
describe('failing mocha', function () {
|
|
72
|
-
this.timeout(20000)
|
|
73
|
-
const expectedTemplate = `
|
|
75
|
+
describe(`failing mocha (${type})`, function () {
|
|
76
|
+
this.timeout(20000)
|
|
77
|
+
const expectedTemplate = `
|
|
74
78
|
test suite 1 - worker
|
|
75
|
-
|
|
79
|
+
✅ is WORKER
|
|
76
80
|
|
|
77
81
|
test suite 2 - failing
|
|
78
82
|
1) should fail
|
|
@@ -86,43 +90,44 @@ describe('failing mocha', function () {
|
|
|
86
90
|
Error: failing test
|
|
87
91
|
`
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
93
|
+
it('should fail in page', async () => {
|
|
94
|
+
let { stdout, code } = await runCli(mochaFailureFixture)
|
|
95
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
96
|
+
stdout = removeTimings(stdout)
|
|
97
|
+
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
98
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
99
|
+
assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('should fail in worker', async () => {
|
|
103
|
+
let { stdout, code } = await runCli(mochaFailureFixture, '--worker --page=false')
|
|
104
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
105
|
+
stdout = removeTimings(stdout)
|
|
106
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
107
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
108
|
+
assert.ok(stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
it('should fail in serviceworker', async () => {
|
|
112
|
+
let { stdout, code } = await runCli(mochaFailureFixture, '--serviceworker --page=false')
|
|
113
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
114
|
+
stdout = removeTimings(stdout)
|
|
115
|
+
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
116
|
+
assert.ok(stdout.includes(expected), 'stdout contains expected test output')
|
|
117
|
+
assert.ok(stdout.includes('Running mocha serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('should fail in page and not run in worker', async () => {
|
|
121
|
+
let { stdout, code } = await runCli(mochaFailureFixture, '--worker')
|
|
122
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
123
|
+
stdout = removeTimings(stdout)
|
|
124
|
+
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
125
|
+
let found = stdout.indexOf(expected)
|
|
126
|
+
assert.ok(found > -1, 'stdout contains expected test output')
|
|
127
|
+
found = stdout.indexOf(expected, found + 1)
|
|
128
|
+
assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
|
|
129
|
+
assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in page')
|
|
130
|
+
assert.ok(!stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
|
|
131
|
+
})
|
|
127
132
|
})
|
|
128
|
-
}
|
|
133
|
+
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import assert from 'assert'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import { fileURLToPath } from 'url'
|
|
6
|
+
import { runCommand } from './common.js'
|
|
7
|
+
|
|
8
|
+
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
7
9
|
|
|
8
|
-
const
|
|
9
|
-
const bareSyncFailureFixture = path.join(__dirname, 'fixtures/bare-sync-failure')
|
|
10
|
-
const bareAsyncFixture = path.join(__dirname, 'fixtures/bare-async')
|
|
11
|
-
const bareAsyncFailureFixture = path.join(__dirname, 'fixtures/bare-async-failure')
|
|
10
|
+
const cli = path.join(__dirname, '../polendina-node-cli.js')
|
|
12
11
|
|
|
13
12
|
function runCli (mode, cwd) {
|
|
14
13
|
return runCommand(`${cli} ${mode} test*.js`, cwd)
|
|
@@ -18,40 +17,46 @@ function removeTiming (stdout) {
|
|
|
18
17
|
return stdout.replace(/Took [\d.]+ seconds/, 'Took X seconds')
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
for (const type of ['cjs', 'esm']) {
|
|
21
|
+
const bareSyncFixture = path.join(__dirname, `fixtures/bare-sync${type === 'esm' ? '-esm' : ''}`)
|
|
22
|
+
const bareSyncFailureFixture = path.join(__dirname, `fixtures/bare-sync-failure${type === 'esm' ? '-esm' : ''}`)
|
|
23
|
+
const bareAsyncFixture = path.join(__dirname, `fixtures/bare-async${type === 'esm' ? '-esm' : ''}`)
|
|
24
|
+
const bareAsyncFailureFixture = path.join(__dirname, `fixtures/bare-async-failure${type === 'esm' ? '-esm' : ''}`)
|
|
25
|
+
|
|
26
|
+
describe(`polendina-node bare-sync (${type})`, function () {
|
|
27
|
+
this.timeout(20000)
|
|
28
|
+
it('pass', async () => {
|
|
29
|
+
const expected =
|
|
25
30
|
`testing is not in worker
|
|
26
31
|
✔ test-1.js
|
|
27
32
|
testing bare fixture
|
|
28
33
|
✔ test-2.js
|
|
29
34
|
Took X seconds
|
|
30
35
|
`
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
const { stdout, code } = await runCli('bare-sync', bareSyncFixture)
|
|
37
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
38
|
+
assert.strictEqual(removeTiming(stdout), expected)
|
|
39
|
+
})
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
it('failure', async () => {
|
|
42
|
+
const expected =
|
|
38
43
|
`testing is not in worker
|
|
39
44
|
✔ test-1.js
|
|
40
45
|
testing bare fixture
|
|
41
46
|
✘ test-2.js
|
|
42
47
|
Took X seconds
|
|
43
48
|
`
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
const { stdout, stderr, code } = await runCli('bare-sync', bareSyncFailureFixture)
|
|
50
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
51
|
+
assert.strictEqual(removeTiming(stdout), expected)
|
|
52
|
+
assert.ok(stderr.includes('AssertionError: faily mcfailface'), 'stderr contains expected output')
|
|
53
|
+
})
|
|
48
54
|
})
|
|
49
|
-
})
|
|
50
55
|
|
|
51
|
-
describe(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
describe(`polendina-node bare-async (${type})`, function () {
|
|
57
|
+
this.timeout(20000)
|
|
58
|
+
it('pass', async () => {
|
|
59
|
+
const expected =
|
|
55
60
|
`testing is not in worker
|
|
56
61
|
✔ test-1.js
|
|
57
62
|
test-2.js
|
|
@@ -60,13 +65,13 @@ testing bare fixture
|
|
|
60
65
|
✔ test2
|
|
61
66
|
Took X seconds
|
|
62
67
|
`
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const { stdout, code } = await runCli('bare-async', bareAsyncFixture)
|
|
69
|
+
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
70
|
+
assert.strictEqual(removeTiming(stdout), expected)
|
|
71
|
+
})
|
|
67
72
|
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
it('failure', async () => {
|
|
74
|
+
const expected =
|
|
70
75
|
`testing is not in worker
|
|
71
76
|
✔ test-1.js
|
|
72
77
|
test-2.js
|
|
@@ -75,9 +80,10 @@ testing bare fixture
|
|
|
75
80
|
✘ test2
|
|
76
81
|
Took X seconds
|
|
77
82
|
`
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
const { stdout, stderr, code } = await runCli('bare-async', bareAsyncFailureFixture)
|
|
84
|
+
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
85
|
+
assert.strictEqual(removeTiming(stdout), expected)
|
|
86
|
+
assert.ok(stderr.includes('AssertionError: faily mcfailface'), 'stderr contains expected output')
|
|
87
|
+
})
|
|
82
88
|
})
|
|
83
|
-
}
|
|
89
|
+
}
|