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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "polendina-test-consumer",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Version ranges for the test frameworks that test/setup.js installs, one runner per temporary consumer, alongside a packed polendina",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"chai": "^6.0.1",
|
|
8
|
+
"mocha": "^12.0.2",
|
|
9
|
+
"tape": "^5.6.3"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.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
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.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
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-async-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.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
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "node test-1.js && node test-2.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
|
}
|
|
@@ -1,19 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-bare-sync-failure",
|
|
3
3
|
"version": "1.0.0",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "node test-1.js && node test-2.js"
|
|
9
|
-
},
|
|
10
|
-
"author": "Rod <rod@vagg.org> (http://r.va.gg/)",
|
|
11
|
-
"repository": {
|
|
12
|
-
"type": "git",
|
|
13
|
-
"url": "https://github.com/rvagg/polendina.git"
|
|
14
|
-
},
|
|
15
|
-
"license": "Apache-2.0",
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"chai": "^6.0.1"
|
|
18
|
-
}
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module"
|
|
19
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
raw fixture
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha",
|
|
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
|
}
|
|
@@ -11,4 +11,8 @@ describe('test suite 1', () => {
|
|
|
11
11
|
it('test case 2', () => {
|
|
12
12
|
assert.ok(true, 'all good')
|
|
13
13
|
})
|
|
14
|
+
|
|
15
|
+
it('test case 3', () => {
|
|
16
|
+
assert.strictEqual(require('!!raw-loader!./fixture.txt').default, 'raw fixture') // eslint-disable-line import/no-webpack-loader-syntax
|
|
17
|
+
})
|
|
14
18
|
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
raw fixture
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fixture-mocha",
|
|
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,6 +1,7 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
3
|
import fixture from './index.js'
|
|
4
|
+
import raw from '!!raw-loader!./fixture.txt' // eslint-disable-line import/no-webpack-loader-syntax
|
|
4
5
|
import { assert } from 'chai'
|
|
5
6
|
|
|
6
7
|
describe('test suite 1', () => {
|
|
@@ -11,4 +12,8 @@ describe('test suite 1', () => {
|
|
|
11
12
|
it('test case 2', () => {
|
|
12
13
|
assert.ok(true, 'all good')
|
|
13
14
|
})
|
|
15
|
+
|
|
16
|
+
it('test case 3', () => {
|
|
17
|
+
assert.strictEqual(raw, 'raw fixture')
|
|
18
|
+
})
|
|
14
19
|
})
|
|
@@ -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,9 +23,9 @@ 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
|
-
console.error(stderr)
|
|
28
|
+
console.error(stdout, stderr)
|
|
33
29
|
}
|
|
34
30
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
35
31
|
const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
|
|
@@ -41,9 +37,9 @@ 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
|
-
console.error(stderr)
|
|
42
|
+
console.error(stdout, stderr)
|
|
47
43
|
}
|
|
48
44
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
49
45
|
const expected = expectedTemplate.replace(/WORKER/, 'in worker')
|
|
@@ -55,9 +51,9 @@ 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
|
-
console.error(stderr)
|
|
56
|
+
console.error(stdout, stderr)
|
|
61
57
|
}
|
|
62
58
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
63
59
|
const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
|
|
@@ -69,9 +65,9 @@ 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
|
-
console.error(stderr)
|
|
70
|
+
console.error(stdout, stderr)
|
|
75
71
|
}
|
|
76
72
|
assert.strictEqual(code, 0, 'exited with zero exit code')
|
|
77
73
|
|
|
@@ -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')
|