polendina 3.3.2 → 3.3.4
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 +81 -49
- package/CHANGELOG.md +12 -0
- package/README.md +11 -0
- package/lib/puppeteer.js +4 -36
- package/lib/webpack.config.js +5 -2
- package/package.json +3 -4
- package/polendina-cli.js +0 -6
- package/polendina.js +1 -1
- package/resources/common-run.js +0 -3
- package/resources/mocha-run.js +1 -6
- 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/fixture.txt +1 -0
- package/test/fixtures/mocha/package.json +1 -15
- package/test/fixtures/mocha/test-1.js +4 -0
- package/test/fixtures/mocha-esm/fixture.txt +1 -0
- package/test/fixtures/mocha-esm/package.json +2 -16
- package/test/fixtures/mocha-esm/test-1.js +5 -0
- 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 +14 -18
- package/test/test-bare-sync.js +14 -18
- package/test/test-mocha.js +28 -27
- package/test/test-packed-install.js +29 -69
- package/test/test-polendina-node.js +11 -21
- package/test/test-tape.js +14 -18
- package/test/test-webpack-merge.js +4 -8
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,9 +19,9 @@ 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
|
-
console.error(stderr)
|
|
24
|
+
console.error(stdout, stderr)
|
|
29
25
|
}
|
|
30
26
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
31
27
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -37,9 +33,9 @@ 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
|
-
console.error(stderr)
|
|
38
|
+
console.error(stdout, stderr)
|
|
43
39
|
}
|
|
44
40
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
45
41
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -51,9 +47,9 @@ 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
|
-
console.error(stderr)
|
|
52
|
+
console.error(stdout, stderr)
|
|
57
53
|
}
|
|
58
54
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
59
55
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -65,9 +61,9 @@ 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
|
-
console.error(stderr)
|
|
66
|
+
console.error(stdout, stderr)
|
|
71
67
|
}
|
|
72
68
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
73
69
|
|
|
@@ -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,39 +1,40 @@
|
|
|
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
|
+
${ticks[consumerName]} test case 3
|
|
24
25
|
|
|
25
26
|
test suite 2 - worker
|
|
26
|
-
|
|
27
|
+
${ticks[consumerName]} is WORKER
|
|
27
28
|
|
|
28
29
|
test suite 3
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
${ticks[consumerName]} test case 1
|
|
31
|
+
${ticks[consumerName]} test case 2
|
|
31
32
|
`
|
|
32
33
|
|
|
33
34
|
it('should run in page', async () => {
|
|
34
|
-
const { stdout, stderr, code } = await runCli(mochaFixture)
|
|
35
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, [])
|
|
35
36
|
if (code !== 0) {
|
|
36
|
-
console.error(stderr)
|
|
37
|
+
console.error(stdout, stderr)
|
|
37
38
|
}
|
|
38
39
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
39
40
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -45,9 +46,9 @@ for (const type of ['cjs', 'esm']) {
|
|
|
45
46
|
})
|
|
46
47
|
|
|
47
48
|
it('should run in worker', async () => {
|
|
48
|
-
const { stdout, stderr, code } = await runCli(mochaFixture, '--worker --page=false')
|
|
49
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, ['--worker', '--page=false'])
|
|
49
50
|
if (code !== 0) {
|
|
50
|
-
console.error(stderr)
|
|
51
|
+
console.error(stdout, stderr)
|
|
51
52
|
}
|
|
52
53
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
53
54
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -59,9 +60,9 @@ for (const type of ['cjs', 'esm']) {
|
|
|
59
60
|
})
|
|
60
61
|
|
|
61
62
|
it('should run in serviceworker', async () => {
|
|
62
|
-
const { stdout, stderr, code } = await runCli(mochaFixture, '--serviceworker --page=false')
|
|
63
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, ['--serviceworker', '--page=false'])
|
|
63
64
|
if (code !== 0) {
|
|
64
|
-
console.error(stderr)
|
|
65
|
+
console.error(stdout, stderr)
|
|
65
66
|
}
|
|
66
67
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
67
68
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -73,9 +74,9 @@ for (const type of ['cjs', 'esm']) {
|
|
|
73
74
|
})
|
|
74
75
|
|
|
75
76
|
it('should run in page, worker and serviceworker', async () => {
|
|
76
|
-
const { stdout, stderr, code } = await runCli(mochaFixture, '--worker --serviceworker')
|
|
77
|
+
const { stdout, stderr, code } = await runCli(consumerName, mochaFixture, ['--worker', '--serviceworker'])
|
|
77
78
|
if (code !== 0) {
|
|
78
|
-
console.error(stderr)
|
|
79
|
+
console.error(stdout, stderr)
|
|
79
80
|
}
|
|
80
81
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
81
82
|
|
|
@@ -102,11 +103,11 @@ for (const type of ['cjs', 'esm']) {
|
|
|
102
103
|
})
|
|
103
104
|
})
|
|
104
105
|
|
|
105
|
-
describe(`failing mocha (${type})`, function () {
|
|
106
|
+
describe(`failing mocha (${type}, ${consumerName})`, function () {
|
|
106
107
|
this.timeout(60000)
|
|
107
108
|
const expectedTemplate = `
|
|
108
109
|
test suite 1 - worker
|
|
109
|
-
|
|
110
|
+
${ticks[consumerName]} is WORKER
|
|
110
111
|
|
|
111
112
|
test suite 2 - failing
|
|
112
113
|
1) should fail
|
|
@@ -121,7 +122,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
121
122
|
`
|
|
122
123
|
|
|
123
124
|
it('should fail in page', async () => {
|
|
124
|
-
let { stdout, code } = await runCli(mochaFailureFixture)
|
|
125
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, [])
|
|
125
126
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
126
127
|
stdout = removeTimings(stdout)
|
|
127
128
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -133,7 +134,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
133
134
|
})
|
|
134
135
|
|
|
135
136
|
it('should fail in worker', async () => {
|
|
136
|
-
let { stdout, code } = await runCli(mochaFailureFixture, '--worker --page=false')
|
|
137
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, ['--worker', '--page=false'])
|
|
137
138
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
138
139
|
stdout = removeTimings(stdout)
|
|
139
140
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -145,7 +146,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
145
146
|
})
|
|
146
147
|
|
|
147
148
|
it('should fail in serviceworker', async () => {
|
|
148
|
-
let { stdout, code } = await runCli(mochaFailureFixture, '--serviceworker --page=false')
|
|
149
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, ['--serviceworker', '--page=false'])
|
|
149
150
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
150
151
|
stdout = removeTimings(stdout)
|
|
151
152
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -157,7 +158,7 @@ for (const type of ['cjs', 'esm']) {
|
|
|
157
158
|
})
|
|
158
159
|
|
|
159
160
|
it('should fail in page and not run in worker', async () => {
|
|
160
|
-
let { stdout, code } = await runCli(mochaFailureFixture, '--worker')
|
|
161
|
+
let { stdout, code } = await runCli(consumerName, mochaFailureFixture, ['--worker'])
|
|
161
162
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
162
163
|
stdout = removeTimings(stdout)
|
|
163
164
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -1,87 +1,47 @@
|
|
|
1
|
-
/* globals describe it
|
|
1
|
+
/* globals describe it */
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
// repository
|
|
5
|
-
//
|
|
3
|
+
// setup.js installs polendina from a packed tarball into consumers outside
|
|
4
|
+
// this repository; check that layout is the hoisted one a real install has
|
|
5
|
+
// and that each consumer carries only its own runner
|
|
6
6
|
|
|
7
7
|
import assert from 'assert'
|
|
8
8
|
import fs from 'fs'
|
|
9
|
-
import os from 'os'
|
|
10
9
|
import path from 'path'
|
|
11
|
-
import {
|
|
12
|
-
import { fileURLToPath } from 'url'
|
|
10
|
+
import { consumers } from './common.js'
|
|
13
11
|
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const puppeteerVersion = JSON.parse(fs.readFileSync(path.join(root, 'node_modules/puppeteer/package.json'))).version
|
|
17
|
-
|
|
18
|
-
function sh (command, cwd) {
|
|
19
|
-
return new Promise((resolve, reject) => {
|
|
20
|
-
exec(command, { cwd, env: { ...process.env, PUPPETEER_SKIP_DOWNLOAD: '1' } }, (err, stdout, stderr) => {
|
|
21
|
-
if (err) {
|
|
22
|
-
return reject(new Error(`${command}\n${stderr}`))
|
|
23
|
-
}
|
|
24
|
-
resolve(stdout.toString())
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function cli (cwd, args) {
|
|
30
|
-
return new Promise((resolve) => {
|
|
31
|
-
const bin = path.join(cwd, 'node_modules/polendina/polendina-cli.js')
|
|
32
|
-
execFile(process.execPath, [bin, ...args], { cwd }, (err, stdout, stderr) => {
|
|
33
|
-
resolve({ code: err ? err.code : 0, stdout: stdout.toString(), stderr: stderr.toString() })
|
|
34
|
-
})
|
|
35
|
-
})
|
|
36
|
-
}
|
|
12
|
+
const present = (dir, ...segments) => fs.promises.access(path.join(dir, ...segments))
|
|
13
|
+
const absent = (dir, ...segments) => assert.rejects(present(dir, ...segments))
|
|
37
14
|
|
|
38
15
|
describe('packed install', function () {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
consumer = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'polendina-consumer-'))
|
|
44
|
-
const [{ filename }] = JSON.parse(await sh(`npm pack --json --pack-destination "${consumer}"`, root))
|
|
45
|
-
await fs.promises.writeFile(path.join(consumer, 'package.json'), JSON.stringify({ name: 'consumer', version: '1.0.0', private: true }))
|
|
46
|
-
await fs.promises.writeFile(path.join(consumer, 'test-tape.js'), `
|
|
47
|
-
const tape = require('tape')
|
|
48
|
-
tape('packed', (t) => { t.ok(true, 'runs'); t.end() })
|
|
49
|
-
`)
|
|
50
|
-
await fs.promises.writeFile(path.join(consumer, 'test-mocha.js'), `
|
|
51
|
-
/* globals describe it */
|
|
52
|
-
describe('packed', () => { it('runs', () => { if (!true) throw new Error('nope') }) })
|
|
53
|
-
`)
|
|
54
|
-
await sh(`npm install --no-audit --no-fund --no-package-lock --prefer-offline "./${filename}" tape mocha puppeteer@${puppeteerVersion}`, consumer)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
after(async () => {
|
|
58
|
-
if (consumer) {
|
|
59
|
-
await fs.promises.rm(consumer, { recursive: true, force: true })
|
|
16
|
+
it('hoists polendina dependencies into every consumer tree', async () => {
|
|
17
|
+
for (const dir of Object.values(consumers())) {
|
|
18
|
+
await absent(dir, 'node_modules/polendina/node_modules/stream-browserify')
|
|
19
|
+
await present(dir, 'node_modules/stream-browserify')
|
|
60
20
|
}
|
|
61
21
|
})
|
|
62
22
|
|
|
63
|
-
it('
|
|
64
|
-
|
|
65
|
-
await
|
|
23
|
+
it('installs each runner only in its own consumer', async () => {
|
|
24
|
+
const { mocha, mocha11, tape, bare } = consumers()
|
|
25
|
+
await present(mocha, 'node_modules/mocha')
|
|
26
|
+
await present(mocha11, 'node_modules/mocha')
|
|
27
|
+
await present(tape, 'node_modules/tape')
|
|
28
|
+
await absent(mocha, 'node_modules/tape')
|
|
29
|
+
await absent(tape, 'node_modules/mocha')
|
|
30
|
+
await absent(bare, 'node_modules/mocha')
|
|
31
|
+
await absent(bare, 'node_modules/tape')
|
|
66
32
|
})
|
|
67
33
|
|
|
68
|
-
it('
|
|
69
|
-
const {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
74
|
-
assert.strictEqual(stderr, '', 'no stderr')
|
|
75
|
-
assert.ok(stdout.includes('ok 1 runs'), 'stdout contains tape output')
|
|
34
|
+
it('installs the previous mocha major in its consumer', async () => {
|
|
35
|
+
const { mocha, mocha11 } = consumers()
|
|
36
|
+
const major = (dir) => JSON.parse(fs.readFileSync(path.join(dir, 'node_modules/mocha/package.json'))).version.split('.')[0]
|
|
37
|
+
assert.strictEqual(major(mocha11), '11')
|
|
38
|
+
assert.notStrictEqual(major(mocha), '11')
|
|
76
39
|
})
|
|
77
40
|
|
|
78
|
-
it('
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
41
|
+
it('does not install mocha or tape in polendina itself', async () => {
|
|
42
|
+
for (const dir of Object.values(consumers())) {
|
|
43
|
+
await absent(dir, 'node_modules/polendina/node_modules/mocha')
|
|
44
|
+
await absent(dir, 'node_modules/polendina/node_modules/tape')
|
|
82
45
|
}
|
|
83
|
-
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
84
|
-
assert.strictEqual(stderr, '', 'no stderr')
|
|
85
|
-
assert.ok(stdout.includes('1 passing'), 'stdout contains mocha output')
|
|
86
46
|
})
|
|
87
47
|
})
|
|
@@ -1,27 +1,17 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
3
|
import assert from 'assert'
|
|
4
|
-
import
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
|
-
import { runCommand } from './common.js'
|
|
7
|
-
|
|
8
|
-
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
|
-
|
|
10
|
-
const cli = path.join(__dirname, '../polendina-node-cli.js')
|
|
11
|
-
|
|
12
|
-
function runCli (mode, cwd) {
|
|
13
|
-
return runCommand(`${cli} ${mode} test*.js`, cwd)
|
|
14
|
-
}
|
|
4
|
+
import { runNodeCli } from './common.js'
|
|
15
5
|
|
|
16
6
|
function removeTiming (stdout) {
|
|
17
7
|
return stdout.replace(/Took [\d.]+ seconds/, 'Took X seconds')
|
|
18
8
|
}
|
|
19
9
|
|
|
20
10
|
for (const type of ['cjs', 'esm']) {
|
|
21
|
-
const bareSyncFixture =
|
|
22
|
-
const bareSyncFailureFixture =
|
|
23
|
-
const bareAsyncFixture =
|
|
24
|
-
const bareAsyncFailureFixture =
|
|
11
|
+
const bareSyncFixture = `bare-sync${type === 'esm' ? '-esm' : ''}`
|
|
12
|
+
const bareSyncFailureFixture = `bare-sync-failure${type === 'esm' ? '-esm' : ''}`
|
|
13
|
+
const bareAsyncFixture = `bare-async${type === 'esm' ? '-esm' : ''}`
|
|
14
|
+
const bareAsyncFailureFixture = `bare-async-failure${type === 'esm' ? '-esm' : ''}`
|
|
25
15
|
|
|
26
16
|
describe(`polendina-node bare-sync (${type})`, function () {
|
|
27
17
|
this.timeout(60000)
|
|
@@ -33,9 +23,9 @@ testing bare fixture
|
|
|
33
23
|
✔ test-2.js
|
|
34
24
|
Took X seconds
|
|
35
25
|
`
|
|
36
|
-
const { stdout, stderr, code } = await
|
|
26
|
+
const { stdout, stderr, code } = await runNodeCli('bare', bareSyncFixture, 'bare-sync')
|
|
37
27
|
if (code !== 0) {
|
|
38
|
-
console.error(stderr)
|
|
28
|
+
console.error(stdout, stderr)
|
|
39
29
|
}
|
|
40
30
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
41
31
|
assert.strictEqual(removeTiming(stdout), expected)
|
|
@@ -49,7 +39,7 @@ testing bare fixture
|
|
|
49
39
|
✘ test-2.js
|
|
50
40
|
Took X seconds
|
|
51
41
|
`
|
|
52
|
-
const { stdout, stderr, code } = await
|
|
42
|
+
const { stdout, stderr, code } = await runNodeCli('bare', bareSyncFailureFixture, 'bare-sync')
|
|
53
43
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
54
44
|
assert.strictEqual(removeTiming(stdout), expected)
|
|
55
45
|
assert.ok(stderr.includes('AssertionError: faily mcfailface'), 'stderr contains expected output')
|
|
@@ -68,9 +58,9 @@ testing bare fixture
|
|
|
68
58
|
✔ test2
|
|
69
59
|
Took X seconds
|
|
70
60
|
`
|
|
71
|
-
const { stdout, stderr, code } = await
|
|
61
|
+
const { stdout, stderr, code } = await runNodeCli('bare', bareAsyncFixture, 'bare-async')
|
|
72
62
|
if (code !== 0) {
|
|
73
|
-
console.error(stderr)
|
|
63
|
+
console.error(stdout, stderr)
|
|
74
64
|
}
|
|
75
65
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
76
66
|
assert.strictEqual(removeTiming(stdout), expected)
|
|
@@ -86,7 +76,7 @@ testing bare fixture
|
|
|
86
76
|
✘ test2
|
|
87
77
|
Took X seconds
|
|
88
78
|
`
|
|
89
|
-
const { stdout, stderr, code } = await
|
|
79
|
+
const { stdout, stderr, code } = await runNodeCli('bare', bareAsyncFailureFixture, 'bare-async')
|
|
90
80
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
91
81
|
assert.strictEqual(removeTiming(stdout), expected)
|
|
92
82
|
assert.ok(stderr.includes('AssertionError: faily mcfailface'), 'stderr contains expected output')
|
package/test/test-tape.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 tapeFixture =
|
|
12
|
-
const tapeFailureFixture =
|
|
7
|
+
const tapeFixture = `tape${type === 'esm' ? '-esm' : ''}`
|
|
8
|
+
const tapeFailureFixture = `tape-failure${type === 'esm' ? '-esm' : ''}`
|
|
13
9
|
|
|
14
10
|
describe(`basic tape (${type})`, function () {
|
|
15
11
|
this.timeout(60000)
|
|
@@ -37,9 +33,9 @@ ok 5 all good
|
|
|
37
33
|
`
|
|
38
34
|
|
|
39
35
|
it('should run in page', async () => {
|
|
40
|
-
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape')
|
|
36
|
+
const { stdout, stderr, code } = await runCli('tape', tapeFixture, ['--runner=tape'])
|
|
41
37
|
if (code !== 0) {
|
|
42
|
-
console.error(stderr)
|
|
38
|
+
console.error(stdout, stderr)
|
|
43
39
|
}
|
|
44
40
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
45
41
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -51,9 +47,9 @@ ok 5 all good
|
|
|
51
47
|
})
|
|
52
48
|
|
|
53
49
|
it('should run in worker', async () => {
|
|
54
|
-
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape --worker --page=false')
|
|
50
|
+
const { stdout, stderr, code } = await runCli('tape', tapeFixture, ['--runner=tape', '--worker', '--page=false'])
|
|
55
51
|
if (code !== 0) {
|
|
56
|
-
console.error(stderr)
|
|
52
|
+
console.error(stdout, stderr)
|
|
57
53
|
}
|
|
58
54
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
59
55
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -65,9 +61,9 @@ ok 5 all good
|
|
|
65
61
|
})
|
|
66
62
|
|
|
67
63
|
it('should run in serviceworker', async () => {
|
|
68
|
-
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape --serviceworker --page=false')
|
|
64
|
+
const { stdout, stderr, code } = await runCli('tape', tapeFixture, ['--runner=tape', '--serviceworker', '--page=false'])
|
|
69
65
|
if (code !== 0) {
|
|
70
|
-
console.error(stderr)
|
|
66
|
+
console.error(stdout, stderr)
|
|
71
67
|
}
|
|
72
68
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
73
69
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -79,9 +75,9 @@ ok 5 all good
|
|
|
79
75
|
})
|
|
80
76
|
|
|
81
77
|
it('should run in page, worker and serviceworker', async () => {
|
|
82
|
-
const { stdout, stderr, code } = await runCli(tapeFixture, '--runner=tape --worker --serviceworker')
|
|
78
|
+
const { stdout, stderr, code } = await runCli('tape', tapeFixture, ['--runner=tape', '--worker', '--serviceworker'])
|
|
83
79
|
if (code !== 0) {
|
|
84
|
-
console.error(stderr)
|
|
80
|
+
console.error(stdout, stderr)
|
|
85
81
|
}
|
|
86
82
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
87
83
|
|
|
@@ -131,7 +127,7 @@ not ok 2 bork
|
|
|
131
127
|
`
|
|
132
128
|
|
|
133
129
|
it('should fail in page', async () => {
|
|
134
|
-
let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape')
|
|
130
|
+
let { stdout, code } = await runCli('tape', tapeFailureFixture, ['--runner=tape'])
|
|
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/, 'not in worker')
|
|
@@ -143,7 +139,7 @@ not ok 2 bork
|
|
|
143
139
|
})
|
|
144
140
|
|
|
145
141
|
it('should fail in worker', async () => {
|
|
146
|
-
let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --worker --page=false')
|
|
142
|
+
let { stdout, code } = await runCli('tape', tapeFailureFixture, ['--runner=tape', '--worker', '--page=false'])
|
|
147
143
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
148
144
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
149
145
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -155,7 +151,7 @@ not ok 2 bork
|
|
|
155
151
|
})
|
|
156
152
|
|
|
157
153
|
it('should fail in serviceworker', async () => {
|
|
158
|
-
let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --serviceworker --page=false')
|
|
154
|
+
let { stdout, code } = await runCli('tape', tapeFailureFixture, ['--runner=tape', '--serviceworker', '--page=false'])
|
|
159
155
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
160
156
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
161
157
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -167,7 +163,7 @@ not ok 2 bork
|
|
|
167
163
|
})
|
|
168
164
|
|
|
169
165
|
it('should fail in page and not run in worker', async () => {
|
|
170
|
-
let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --worker')
|
|
166
|
+
let { stdout, code } = await runCli('tape', tapeFailureFixture, ['--runner=tape', '--worker'])
|
|
171
167
|
assert.strictEqual(code, 1, 'exited with non-zero exit code')
|
|
172
168
|
stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
|
|
173
169
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -1,12 +1,8 @@
|
|
|
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
|
-
|
|
8
|
-
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
|
-
const webpackMergeFixture = path.join(__dirname, 'fixtures/webpack-merge')
|
|
5
|
+
const webpackMergeFixture = 'webpack-merge'
|
|
10
6
|
|
|
11
7
|
describe('basic webpack-merge', function () {
|
|
12
8
|
this.timeout(60000)
|
|
@@ -16,9 +12,9 @@ assert.ok() is a function
|
|
|
16
12
|
WOOP is set
|
|
17
13
|
✔ test.js
|
|
18
14
|
`
|
|
19
|
-
const { stdout, stderr, code } = await runCli(webpackMergeFixture, '--runner=bare-sync --webpack-config webpack.config.js')
|
|
15
|
+
const { stdout, stderr, code } = await runCli('bare', webpackMergeFixture, ['--runner=bare-sync', '--webpack-config', 'webpack.config.js'])
|
|
20
16
|
if (code !== 0) {
|
|
21
|
-
console.error(stderr)
|
|
17
|
+
console.error(stdout, stderr)
|
|
22
18
|
}
|
|
23
19
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
24
20
|
if (!stdout.includes(expected)) {
|
|
@@ -35,7 +31,7 @@ assert.ok() is a function
|
|
|
35
31
|
`
|
|
36
32
|
const expectedStderr = 'WOOP is not defined'
|
|
37
33
|
|
|
38
|
-
const { stdout, stderr, code } = await runCli(webpackMergeFixture, '--runner=bare-sync')
|
|
34
|
+
const { stdout, stderr, code } = await runCli('bare', webpackMergeFixture, ['--runner=bare-sync'])
|
|
39
35
|
assert.strictEqual(code, 1, 'exited with zero exit code')
|
|
40
36
|
assert.ok(stdout.includes(expectedStdout), 'stdout contains expected test output')
|
|
41
37
|
assert.ok(stderr.includes(expectedStderr), 'stderr contains expected test output')
|