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,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,7 +23,7 @@ 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
28
|
console.error(stderr)
|
|
39
29
|
}
|
|
@@ -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,7 +58,7 @@ 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
63
|
console.error(stderr)
|
|
74
64
|
}
|
|
@@ -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,7 +33,7 @@ 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
38
|
console.error(stderr)
|
|
43
39
|
}
|
|
@@ -51,7 +47,7 @@ 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
52
|
console.error(stderr)
|
|
57
53
|
}
|
|
@@ -65,7 +61,7 @@ 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
66
|
console.error(stderr)
|
|
71
67
|
}
|
|
@@ -79,7 +75,7 @@ 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
80
|
console.error(stderr)
|
|
85
81
|
}
|
|
@@ -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,7 +12,7 @@ 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
17
|
console.error(stderr)
|
|
22
18
|
}
|
|
@@ -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')
|