polendina 1.1.1 → 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.
Files changed (76) hide show
  1. package/.github/dependabot.yml +154 -0
  2. package/.github/workflows/test-and-release.yml +3 -0
  3. package/lib/log.js +8 -8
  4. package/lib/puppeteer.js +3 -5
  5. package/lib/webpack.config.js +8 -12
  6. package/lib/{wrap-loader.js → wrap-loader.cjs} +8 -5
  7. package/package.json +17 -13
  8. package/polendina-cli.js +7 -6
  9. package/polendina-node-cli.js +10 -6
  10. package/polendina.js +39 -18
  11. package/resources/bare-run.js +3 -3
  12. package/resources/bare.js +7 -5
  13. package/resources/common-run.js +23 -26
  14. package/resources/mocha-run.js +4 -5
  15. package/resources/tape-run.js +5 -5
  16. package/resources/test-registry.js +4 -1
  17. package/test/common.js +8 -8
  18. package/test/fixtures/bare-async/package.json +4 -1
  19. package/test/fixtures/bare-async/test-1.js +1 -1
  20. package/test/fixtures/bare-async/test-2.js +1 -1
  21. package/test/fixtures/bare-async-esm/index.js +3 -0
  22. package/test/fixtures/bare-async-esm/package.json +19 -0
  23. package/test/fixtures/bare-async-esm/test-1.js +16 -0
  24. package/test/fixtures/bare-async-esm/test-2.js +11 -0
  25. package/test/fixtures/bare-async-failure/package.json +4 -1
  26. package/test/fixtures/bare-async-failure/test-1.js +1 -1
  27. package/test/fixtures/bare-async-failure/test-2.js +2 -2
  28. package/test/fixtures/bare-async-failure-esm/index.js +3 -0
  29. package/test/fixtures/bare-async-failure-esm/package.json +19 -0
  30. package/test/fixtures/bare-async-failure-esm/test-1.js +16 -0
  31. package/test/fixtures/bare-async-failure-esm/test-2.js +11 -0
  32. package/test/fixtures/bare-sync/package.json +4 -1
  33. package/test/fixtures/bare-sync/test-1.js +1 -1
  34. package/test/fixtures/bare-sync/test-2.js +2 -1
  35. package/test/fixtures/bare-sync-esm/index.js +1 -0
  36. package/test/fixtures/bare-sync-esm/package.json +19 -0
  37. package/test/fixtures/bare-sync-esm/test-1.js +14 -0
  38. package/test/fixtures/bare-sync-esm/test-2.js +7 -0
  39. package/test/fixtures/bare-sync-failure/package.json +4 -1
  40. package/test/fixtures/bare-sync-failure/test-1.js +1 -1
  41. package/test/fixtures/bare-sync-failure/test-2.js +2 -2
  42. package/test/fixtures/bare-sync-failure-esm/index.js +1 -0
  43. package/test/fixtures/bare-sync-failure-esm/package.json +19 -0
  44. package/test/fixtures/bare-sync-failure-esm/test-1.js +14 -0
  45. package/test/fixtures/bare-sync-failure-esm/test-2.js +6 -0
  46. package/test/fixtures/mocha/package.json +2 -1
  47. package/test/fixtures/mocha/test-1.js +1 -1
  48. package/test/fixtures/mocha/test-2.js +1 -1
  49. package/test/fixtures/mocha/test-3.js +1 -1
  50. package/test/fixtures/mocha-esm/index.js +1 -0
  51. package/test/fixtures/{mocha8 → mocha-esm}/package.json +4 -2
  52. package/test/fixtures/{mocha8 → mocha-esm}/test-1.js +2 -2
  53. package/test/fixtures/{mocha8 → mocha-esm}/test-2.js +1 -1
  54. package/test/fixtures/{mocha8 → mocha-esm}/test-3.js +2 -2
  55. package/test/fixtures/mocha-failure/package.json +2 -1
  56. package/test/fixtures/mocha-failure/test.js +1 -1
  57. package/test/fixtures/mocha-failure-esm/package.json +20 -0
  58. package/test/fixtures/mocha-failure-esm/test.js +24 -0
  59. package/test/fixtures/tape/package.json +1 -1
  60. package/test/fixtures/tape-esm/index.js +1 -0
  61. package/test/fixtures/tape-esm/package.json +19 -0
  62. package/test/fixtures/tape-esm/test.js +47 -0
  63. package/test/fixtures/tape-failure/package.json +1 -1
  64. package/test/fixtures/tape-failure-esm/package.json +19 -0
  65. package/test/fixtures/tape-failure-esm/test.js +29 -0
  66. package/test/fixtures/webpack-merge/package.json +4 -1
  67. package/test/fixtures/webpack-merge/test.js +3 -4
  68. package/test/fixtures/webpack-merge/webpack.config.js +3 -3
  69. package/test/test-bare-async.js +92 -87
  70. package/test/test-bare-sync.js +92 -87
  71. package/test/test-mocha.js +101 -96
  72. package/test/test-polendina-node.js +44 -38
  73. package/test/test-tape.js +95 -90
  74. package/test/test-webpack-merge.js +11 -9
  75. package/CHANGELOG.md +0 -11
  76. package/test/fixtures/mocha8/index.js +0 -1
@@ -1,78 +1,82 @@
1
1
  /* globals describe it */
2
2
 
3
- const assert = require('assert')
4
- const path = require('path')
5
- const { runCli } = require('./common')
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 mochaFixture = path.join(__dirname, 'fixtures/mocha')
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
- describe('basic mocha', function () {
15
- this.timeout(20000)
16
- const expectedTemplate = `
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
- ✓ test case 1
19
- ✓ test case 2
22
+ ✅ test case 1
23
+ ✅ test case 2
20
24
 
21
25
  test suite 2 - worker
22
- ✓ is WORKER
26
+ ✅ is WORKER
23
27
 
24
28
  test suite 3
25
- ✓ test case 1
26
- ✓ test case 2
29
+ ✅ test case 1
30
+ ✅ test case 2
27
31
  `
28
32
 
29
- it('should run in page', async () => {
30
- const { stdout, code } = await runCli(mochaFixture)
31
- assert.strictEqual(code, 0, 'exited with zero exit code')
32
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
33
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
34
- assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in page')
35
- })
36
-
37
- it('should run in worker', async () => {
38
- const { stdout, code } = await runCli(mochaFixture, '--worker --page=false')
39
- assert.strictEqual(code, 0, 'exited with zero exit code')
40
- const expected = expectedTemplate.replace(/WORKER/, 'in worker')
41
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
42
- assert.ok(stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
43
- })
44
-
45
- it('should run in serviceworker', async () => {
46
- const { stdout, code } = await runCli(mochaFixture, '--serviceworker --page=false')
47
- assert.strictEqual(code, 0, 'exited with zero exit code')
48
- const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
49
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
50
- assert.ok(stdout.includes('Running mocha serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
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
- it('should run in page, worker and serviceworker', async () => {
54
- const { stdout, code } = await runCli(mochaFixture, '--worker --serviceworker')
55
- assert.strictEqual(code, 0, 'exited with zero exit code')
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
- ✓ is WORKER
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
- it('should fail in page', async () => {
90
- let { stdout, code } = await runCli(mochaFailureFixture)
91
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
92
- stdout = removeTimings(stdout)
93
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
94
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
95
- assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in worker')
96
- })
97
-
98
- it('should fail in worker', async () => {
99
- let { stdout, code } = await runCli(mochaFailureFixture, '--worker --page=false')
100
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
101
- stdout = removeTimings(stdout)
102
- const expected = expectedTemplate.replace(/WORKER/, 'in worker')
103
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
104
- assert.ok(stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
105
- })
106
-
107
- it('should fail in serviceworker', async () => {
108
- let { stdout, code } = await runCli(mochaFailureFixture, '--serviceworker --page=false')
109
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
110
- stdout = removeTimings(stdout)
111
- const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
112
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
113
- assert.ok(stdout.includes('Running mocha serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
114
- })
115
-
116
- it('should fail in page and not run in worker', async () => {
117
- let { stdout, code } = await runCli(mochaFailureFixture, '--worker')
118
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
119
- stdout = removeTimings(stdout)
120
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
121
- let found = stdout.indexOf(expected)
122
- assert.ok(found > -1, 'stdout contains expected test output')
123
- found = stdout.indexOf(expected, found + 1)
124
- assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
125
- assert.ok(stdout.includes('Running mocha page tests with Puppeteer'), 'stdout contains expected output for running in page')
126
- assert.ok(!stdout.includes('Running mocha worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
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
- const assert = require('assert')
4
- const path = require('path')
5
- const { runCommand } = require('./common')
6
- const cli = path.join(__dirname, '../polendina-node-cli.js')
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 bareSyncFixture = path.join(__dirname, 'fixtures/bare-sync')
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
- describe('polendina-node bare-sync', function () {
22
- this.timeout(20000)
23
- it('pass', async () => {
24
- const expected =
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
- const { stdout, code } = await runCli('bare-sync', bareSyncFixture)
32
- assert.strictEqual(code, 0, 'exited with zero exit code')
33
- assert.strictEqual(removeTiming(stdout), expected)
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
- it('failure', async () => {
37
- const expected =
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
- const { stdout, stderr, code } = await runCli('bare-sync', bareSyncFailureFixture)
45
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
46
- assert.strictEqual(removeTiming(stdout), expected)
47
- assert.ok(stderr.includes('AssertionError [ERR_ASSERTION]: \'nope\' != \'faily mcfailface\''), 'stderr contains expected output')
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('polendina-node bare-async', function () {
52
- this.timeout(20000)
53
- it('pass', async () => {
54
- const expected =
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
- const { stdout, code } = await runCli('bare-async', bareAsyncFixture)
64
- assert.strictEqual(code, 0, 'exited with zero exit code')
65
- assert.strictEqual(removeTiming(stdout), expected)
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
- it('failure', async () => {
69
- const expected =
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
- const { stdout, stderr, code } = await runCli('bare-async', bareAsyncFailureFixture)
79
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
80
- assert.strictEqual(removeTiming(stdout), expected)
81
- assert.ok(stderr.includes('AssertionError [ERR_ASSERTION]: \'nope\' != \'faily mcfailface\''), 'stderr contains expected output')
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
+ }
package/test/test-tape.js CHANGED
@@ -1,15 +1,19 @@
1
1
  /* globals describe it */
2
2
 
3
- const assert = require('assert')
4
- const path = require('path')
5
- const { runCli } = require('./common')
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 tapeFixture = path.join(__dirname, 'fixtures/tape')
8
- const tapeFailureFixture = path.join(__dirname, 'fixtures/tape-failure')
8
+ const __dirname = fileURLToPath(path.dirname(import.meta.url))
9
9
 
10
- describe('basic tape', function () {
11
- this.timeout(20000)
12
- const expectedTemplate = `
10
+ for (const type of ['cjs', 'esm']) {
11
+ const tapeFixture = path.join(__dirname, `fixtures/tape${type === 'esm' ? '-esm' : ''}`)
12
+ const tapeFailureFixture = path.join(__dirname, `fixtures/tape-failure${type === 'esm' ? '-esm' : ''}`)
13
+
14
+ describe(`basic tape (${type})`, function () {
15
+ this.timeout(20000)
16
+ const expectedTemplate = `
13
17
  TAP version 13
14
18
  # test suite 1
15
19
  # test case 1
@@ -32,51 +36,51 @@ ok 5 all good
32
36
  # ok
33
37
  `
34
38
 
35
- it('should run in page', async () => {
36
- const { stdout, code } = await runCli(tapeFixture, '--runner=tape')
37
- assert.strictEqual(code, 0, 'exited with zero exit code')
38
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
39
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
40
- assert.ok(stdout.includes('Running tape page tests with Puppeteer'), 'stdout contains expected output for running in page')
41
- })
42
-
43
- it('should run in worker', async () => {
44
- const { stdout, code } = await runCli(tapeFixture, '--runner=tape --worker --page=false')
45
- assert.strictEqual(code, 0, 'exited with zero exit code')
46
- const expected = expectedTemplate.replace(/WORKER/, 'in worker')
47
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
48
- assert.ok(stdout.includes('Running tape worker tests with Puppeteer'), 'stdout contains expected output for running in page')
49
- })
50
-
51
- it('should run in serviceworker', async () => {
52
- const { stdout, code } = await runCli(tapeFixture, '--runner=tape --serviceworker --page=false')
53
- assert.strictEqual(code, 0, 'exited with zero exit code')
54
- const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
55
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
56
- assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
57
- })
58
-
59
- it('should run in page, worker and serviceworker', async () => {
60
- const { stdout, code } = await runCli(tapeFixture, '--runner=tape --worker --serviceworker')
61
- assert.strictEqual(code, 0, 'exited with zero exit code')
62
-
63
- let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
64
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
65
- assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
66
-
67
- expected = expectedTemplate.replace(/WORKER/, 'in worker')
68
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
69
- assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
70
-
71
- expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
72
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
73
- assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
39
+ it('should run in page', async () => {
40
+ const { stdout, code } = await runCli(tapeFixture, '--runner=tape')
41
+ assert.strictEqual(code, 0, 'exited with zero exit code')
42
+ const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
43
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
44
+ assert.ok(stdout.includes('Running tape page tests with Puppeteer'), 'stdout contains expected output for running in page')
45
+ })
46
+
47
+ it('should run in worker', async () => {
48
+ const { stdout, code } = await runCli(tapeFixture, '--runner=tape --worker --page=false')
49
+ assert.strictEqual(code, 0, 'exited with zero exit code')
50
+ const expected = expectedTemplate.replace(/WORKER/, 'in worker')
51
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
52
+ assert.ok(stdout.includes('Running tape worker tests with Puppeteer'), 'stdout contains expected output for running in page')
53
+ })
54
+
55
+ it('should run in serviceworker', async () => {
56
+ const { stdout, code } = await runCli(tapeFixture, '--runner=tape --serviceworker --page=false')
57
+ assert.strictEqual(code, 0, 'exited with zero exit code')
58
+ const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
59
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
60
+ assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
61
+ })
62
+
63
+ it('should run in page, worker and serviceworker', async () => {
64
+ const { stdout, code } = await runCli(tapeFixture, '--runner=tape --worker --serviceworker')
65
+ assert.strictEqual(code, 0, 'exited with zero exit code')
66
+
67
+ let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
68
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
69
+ assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
70
+
71
+ expected = expectedTemplate.replace(/WORKER/, 'in worker')
72
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
73
+ assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
74
+
75
+ expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
76
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
77
+ assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
78
+ })
74
79
  })
75
- })
76
80
 
77
- describe('failing tape', function () {
78
- this.timeout(20000)
79
- const expectedTemplate = `
81
+ describe(`failing tape (${type})`, function () {
82
+ this.timeout(20000)
83
+ const expectedTemplate = `
80
84
  TAP version 13
81
85
  # test suite 1 - worker
82
86
  # is WORKER
@@ -96,43 +100,44 @@ not ok 2 bork
96
100
  # fail 1
97
101
  `
98
102
 
99
- it('should fail in page', async () => {
100
- let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape')
101
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
102
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
103
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
104
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
105
- assert.ok(stdout.includes('Running tape page tests with Puppeteer'), 'stdout contains expected output for running in worker')
106
- })
107
-
108
- it('should fail in worker', async () => {
109
- let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --worker --page=false')
110
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
111
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
112
- const expected = expectedTemplate.replace(/WORKER/, 'in worker')
113
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
114
- assert.ok(stdout.includes('Running tape worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
115
- })
116
-
117
- it('should fail in serviceworker', async () => {
118
- let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --serviceworker --page=false')
119
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
120
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
121
- const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
122
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
123
- assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
124
- })
125
-
126
- it('should fail in page and not run in worker', async () => {
127
- let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --worker')
128
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
129
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
130
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
131
- let found = stdout.indexOf(expected)
132
- assert.ok(found > -1, 'stdout contains expected test output')
133
- found = stdout.indexOf(expected, found + 1)
134
- assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
135
- assert.ok(stdout.includes('Running tape page tests with Puppeteer'), 'stdout contains expected output for running in page')
136
- assert.ok(!stdout.includes('Running tape worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
103
+ it('should fail in page', async () => {
104
+ let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape')
105
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
106
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
107
+ const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
108
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
109
+ assert.ok(stdout.includes('Running tape page tests with Puppeteer'), 'stdout contains expected output for running in worker')
110
+ })
111
+
112
+ it('should fail in worker', async () => {
113
+ let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --worker --page=false')
114
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
115
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
116
+ const expected = expectedTemplate.replace(/WORKER/, 'in worker')
117
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
118
+ assert.ok(stdout.includes('Running tape worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
119
+ })
120
+
121
+ it('should fail in serviceworker', async () => {
122
+ let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --serviceworker --page=false')
123
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
124
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
125
+ const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
126
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
127
+ assert.ok(stdout.includes('Running tape serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
128
+ })
129
+
130
+ it('should fail in page and not run in worker', async () => {
131
+ let { stdout, code } = await runCli(tapeFailureFixture, '--runner=tape --worker')
132
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
133
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
134
+ const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
135
+ let found = stdout.indexOf(expected)
136
+ assert.ok(found > -1, 'stdout contains expected test output')
137
+ found = stdout.indexOf(expected, found + 1)
138
+ assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
139
+ assert.ok(stdout.includes('Running tape page tests with Puppeteer'), 'stdout contains expected output for running in page')
140
+ assert.ok(!stdout.includes('Running tape worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
141
+ })
137
142
  })
138
- })
143
+ }
@@ -1,33 +1,35 @@
1
1
  /* globals describe it */
2
2
 
3
- const assert = require('assert')
4
- const path = require('path')
5
- const { runCli } = require('./common')
3
+ import assert from 'assert'
4
+ import path from 'path'
5
+ import { fileURLToPath } from 'url'
6
+ import { runCli } from './common.js'
6
7
 
8
+ const __dirname = fileURLToPath(path.dirname(import.meta.url))
7
9
  const webpackMergeFixture = path.join(__dirname, 'fixtures/webpack-merge')
8
10
 
9
11
  describe('basic webpack-merge', function () {
10
12
  this.timeout(20000)
11
- it('should run plain', async () => {
13
+ it('should run with a custom config', async () => {
12
14
  const expected = `
13
15
  assert.ok() is a function
14
- querystring.parse() is a function
16
+ WOOP is set
15
17
  ✔ test.js
16
18
  `
17
- const { stdout, code } = await runCli(webpackMergeFixture, '--runner=bare-sync')
19
+ const { stdout, code } = await runCli(webpackMergeFixture, '--runner=bare-sync --webpack-config webpack.config.js')
18
20
  assert.strictEqual(code, 0, 'exited with zero exit code')
19
21
  assert.ok(stdout.includes(expected), 'stdout contains expected test output')
20
22
  assert.ok(stdout.includes('Running bare-sync page tests with Puppeteer'), 'stdout contains expected output for running in page')
21
23
  })
22
24
 
23
- it('should fail with custom config', async () => {
25
+ it('should fail without a custom config', async () => {
24
26
  const expectedStdout = `
25
27
  assert.ok() is a function
26
28
  ✘ test.js
27
29
  `
28
- const expectedStderr = '\'undefined\' === \'function\''
30
+ const expectedStderr = 'WOOP is not defined'
29
31
 
30
- const { stdout, stderr, code } = await runCli(webpackMergeFixture, '--runner=bare-sync --webpack-config webpack.config.js')
32
+ const { stdout, stderr, code } = await runCli(webpackMergeFixture, '--runner=bare-sync')
31
33
  assert.strictEqual(code, 1, 'exited with zero exit code')
32
34
  assert.ok(stdout.includes(expectedStdout), 'stdout contains expected test output')
33
35
  assert.ok(stderr.includes(expectedStderr), 'stderr contains expected test output')
package/CHANGELOG.md DELETED
@@ -1,11 +0,0 @@
1
- ### [1.1.1](https://github.com/rvagg/polendina/compare/v1.1.0...v1.1.1) (2021-12-07)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * no build step for release ([b91faf0](https://github.com/rvagg/polendina/commit/b91faf08395e6f8bc44b21d02d94c2136bcac942))
7
-
8
-
9
- ### Trivial Changes
10
-
11
- * add auto-releases ([#17](https://github.com/rvagg/polendina/issues/17)) ([9e71246](https://github.com/rvagg/polendina/commit/9e71246667ba96d8253aa180271728b35e700b45))
@@ -1 +0,0 @@
1
- module.exports = 'polendina test'