polendina 1.0.0 → 2.0.0-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.github/dependabot.yml +154 -0
  2. package/.github/workflows/test-and-release.yml +61 -0
  3. package/lib/log.js +8 -8
  4. package/lib/puppeteer.js +6 -5
  5. package/lib/webpack.config.js +15 -18
  6. package/lib/{wrap-loader.js → wrap-loader.cjs} +10 -7
  7. package/package.json +99 -18
  8. package/polendina-cli.js +7 -6
  9. package/polendina-node-cli.js +10 -6
  10. package/polendina.js +45 -19
  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 +12 -12
  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/mocha-esm/package.json +20 -0
  52. package/test/fixtures/mocha-esm/test-1.js +14 -0
  53. package/test/fixtures/mocha-esm/test-2.js +19 -0
  54. package/test/fixtures/mocha-esm/test-3.js +14 -0
  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 +99 -94
  74. package/test/test-webpack-merge.js +11 -9
  75. package/.github/workflows/main.yml +0 -21
@@ -0,0 +1 @@
1
+ export default 'polendina test'
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "fixture-mocha",
3
+ "version": "1.0.0",
4
+ "description": "test-fixture",
5
+ "main": "index.js",
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": "^4.3.4",
18
+ "mocha": "~9.1.3"
19
+ }
20
+ }
@@ -0,0 +1,14 @@
1
+ /* globals describe it */
2
+
3
+ import fixture from './index.js'
4
+ import { assert } from 'chai'
5
+
6
+ describe('test suite 1', () => {
7
+ it('test case 1', () => {
8
+ assert.strictEqual(fixture, 'polendina test')
9
+ })
10
+
11
+ it('test case 2', () => {
12
+ assert.ok(true, 'all good')
13
+ })
14
+ })
@@ -0,0 +1,19 @@
1
+ /* globals describe it WorkerGlobalScope ServiceWorkerGlobalScope */
2
+
3
+ import { assert } from 'chai'
4
+
5
+ describe('test suite 2 - worker', () => {
6
+ if (typeof ServiceWorkerGlobalScope !== 'undefined' && global instanceof ServiceWorkerGlobalScope) {
7
+ it('is in serviceworker', () => {
8
+ assert.strictEqual(typeof ServiceWorkerGlobalScope, 'function')
9
+ })
10
+ } else if (typeof WorkerGlobalScope !== 'undefined' && global instanceof WorkerGlobalScope) {
11
+ it('is in worker', () => {
12
+ assert.strictEqual(typeof WorkerGlobalScope, 'function')
13
+ })
14
+ } else {
15
+ it('is not in worker', () => {
16
+ assert.strictEqual(typeof WorkerGlobalScope, 'undefined')
17
+ })
18
+ }
19
+ })
@@ -0,0 +1,14 @@
1
+ /* globals describe it */
2
+
3
+ import fixture from './index.js'
4
+ import { assert } from 'chai'
5
+
6
+ describe('test suite 3', () => {
7
+ it('test case 1', () => {
8
+ assert.strictEqual(fixture, 'polendina test')
9
+ })
10
+
11
+ it('test case 2', () => {
12
+ assert.ok(true, 'all good')
13
+ })
14
+ })
@@ -13,6 +13,7 @@
13
13
  "url": "https://github.com/rvagg/polendina.git"
14
14
  },
15
15
  "devDependencies": {
16
- "mocha": "^7.0.0"
16
+ "chai": "^4.3.4",
17
+ "mocha": "~9.1.3"
17
18
  }
18
19
  }
@@ -1,5 +1,5 @@
1
1
  /* globals describe it WorkerGlobalScope ServiceWorkerGlobalScope */
2
- const assert = require('assert')
2
+ const { assert } = require('chai')
3
3
 
4
4
  describe('test suite 1 - worker', () => {
5
5
  if (typeof ServiceWorkerGlobalScope !== 'undefined' && global instanceof ServiceWorkerGlobalScope) {
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "fixture-mocha-failure",
3
+ "version": "1.0.0",
4
+ "description": "test fixture",
5
+ "main": "index.js",
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": "^4.3.4",
18
+ "mocha": "~9.1.3"
19
+ }
20
+ }
@@ -0,0 +1,24 @@
1
+ /* globals describe it WorkerGlobalScope ServiceWorkerGlobalScope */
2
+ import { assert } from 'chai'
3
+
4
+ describe('test suite 1 - worker', () => {
5
+ if (typeof ServiceWorkerGlobalScope !== 'undefined' && global instanceof ServiceWorkerGlobalScope) {
6
+ it('is in serviceworker', () => {
7
+ assert.strictEqual(typeof ServiceWorkerGlobalScope, 'function')
8
+ })
9
+ } else if (typeof WorkerGlobalScope !== 'undefined' && global instanceof WorkerGlobalScope) {
10
+ it('is in worker', () => {
11
+ assert.strictEqual(typeof WorkerGlobalScope, 'function')
12
+ })
13
+ } else {
14
+ it('is not in worker', () => {
15
+ assert.strictEqual(typeof WorkerGlobalScope, 'undefined')
16
+ })
17
+ }
18
+ })
19
+
20
+ describe('test suite 2 - failing', () => {
21
+ it('should fail', () => {
22
+ throw new Error('failing test')
23
+ })
24
+ })
@@ -13,6 +13,6 @@
13
13
  "url": "https://github.com/rvagg/polendina.git"
14
14
  },
15
15
  "devDependencies": {
16
- "tape": "^4.12.1"
16
+ "tape": "~5.3.2"
17
17
  }
18
18
  }
@@ -0,0 +1 @@
1
+ export default 'polendina test'
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "fixture-tape",
3
+ "version": "1.0.0",
4
+ "description": "test fixture",
5
+ "main": "index.js",
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.3.2"
18
+ }
19
+ }
@@ -0,0 +1,47 @@
1
+ /* globals WorkerGlobalScope ServiceWorkerGlobalScope */
2
+
3
+ import tape from 'tape'
4
+ import fixture from './index.js'
5
+
6
+ tape('test suite 1', (t) => {
7
+ t.test('test case 1', (t) => {
8
+ t.strictEqual(fixture, 'polendina test')
9
+ t.end()
10
+ })
11
+
12
+ t.test('test case 2', (t) => {
13
+ t.ok(true, 'all good')
14
+ t.end()
15
+ })
16
+ })
17
+
18
+ tape('test suite 2 - worker', (t) => {
19
+ if (typeof ServiceWorkerGlobalScope !== 'undefined' && global instanceof ServiceWorkerGlobalScope) {
20
+ t.test('is in serviceworker', (t) => {
21
+ t.strictEqual(typeof ServiceWorkerGlobalScope, 'function')
22
+ t.end()
23
+ })
24
+ } else if (typeof WorkerGlobalScope !== 'undefined' && global instanceof WorkerGlobalScope) {
25
+ t.test('is in worker', (t) => {
26
+ t.strictEqual(typeof WorkerGlobalScope, 'function')
27
+ t.end()
28
+ })
29
+ } else {
30
+ t.test('is not in worker', (t) => {
31
+ t.strictEqual(typeof WorkerGlobalScope, 'undefined')
32
+ t.end()
33
+ })
34
+ }
35
+ })
36
+
37
+ tape('test suite 3', (t) => {
38
+ t.test('test case 1', (t) => {
39
+ t.strictEqual(fixture, 'polendina test')
40
+ t.end()
41
+ })
42
+
43
+ t.test('test case 2', (t) => {
44
+ t.ok(true, 'all good')
45
+ t.end()
46
+ })
47
+ })
@@ -13,6 +13,6 @@
13
13
  "url": "https://github.com/rvagg/polendina.git"
14
14
  },
15
15
  "devDependencies": {
16
- "tape": "^4.12.1"
16
+ "tape": "~5.0.1"
17
17
  }
18
18
  }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "fixture-tape-failure",
3
+ "version": "1.0.0",
4
+ "description": "test fixture",
5
+ "main": "index.js",
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.0.1"
18
+ }
19
+ }
@@ -0,0 +1,29 @@
1
+ /* globals WorkerGlobalScope ServiceWorkerGlobalScope */
2
+
3
+ import tape from 'tape'
4
+
5
+ tape('test suite 1 - worker', (t) => {
6
+ if (typeof ServiceWorkerGlobalScope !== 'undefined' && global instanceof ServiceWorkerGlobalScope) {
7
+ t.test('is in serviceworker', (t) => {
8
+ t.strictEqual(typeof ServiceWorkerGlobalScope, 'function')
9
+ t.end()
10
+ })
11
+ } else if (typeof WorkerGlobalScope !== 'undefined' && global instanceof WorkerGlobalScope) {
12
+ t.test('is in worker', (t) => {
13
+ t.strictEqual(typeof WorkerGlobalScope, 'function')
14
+ t.end()
15
+ })
16
+ } else {
17
+ t.test('is not in worker', (t) => {
18
+ t.strictEqual(typeof WorkerGlobalScope, 'undefined')
19
+ t.end()
20
+ })
21
+ }
22
+ })
23
+
24
+ tape('test suite 2 - failure', (t) => {
25
+ t.test('test case 1', (t) => {
26
+ t.fail('bork')
27
+ t.end()
28
+ })
29
+ })
@@ -11,5 +11,8 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/rvagg/polendina.git"
13
13
  },
14
- "license": "Apache-2.0"
14
+ "license": "Apache-2.0",
15
+ "devDependencies": {
16
+ "chai": "^4.3.4"
17
+ }
15
18
  }
@@ -1,7 +1,6 @@
1
- const assert = require('assert')
2
- const qs = require('querystring')
1
+ const { assert } = require('chai')
3
2
 
4
3
  assert.strictEqual(typeof assert.ok, 'function')
5
4
  console.log('assert.ok() is a function')
6
- assert.strictEqual(typeof qs.parse, 'function')
7
- console.log('querystring.parse() is a function')
5
+ assert.strictEqual(WOOP, 'woop') // eslint-disable-line
6
+ console.log('WOOP is set')
@@ -1,5 +1,5 @@
1
+ const webpack = require('webpack')
2
+
1
3
  module.exports = {
2
- node: {
3
- querystring: 'empty'
4
- }
4
+ plugins: [new webpack.DefinePlugin({ WOOP: '"woop"' })]
5
5
  }
@@ -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 bareSyncFixture = path.join(__dirname, 'fixtures/bare-async')
8
- const bareSyncFailureFixture = path.join(__dirname, 'fixtures/bare-async-failure')
8
+ const __dirname = fileURLToPath(path.dirname(import.meta.url))
9
9
 
10
- describe('basic bare-async', function () {
11
- this.timeout(20000)
12
- const expectedTemplate = `
10
+ for (const type of ['cjs', 'esm']) {
11
+ const bareAsyncFixture = path.join(__dirname, `fixtures/bare-async${type === 'esm' ? '-esm' : ''}`)
12
+ const bareAsyncFailureFixture = path.join(__dirname, `fixtures/bare-async-failure${type === 'esm' ? '-esm' : ''}`)
13
+
14
+ describe(`basic bare-async (${type})`, function () {
15
+ this.timeout(20000)
16
+ const expectedTemplate = `
13
17
  testing is WORKER
14
18
  ✔ test-1.js
15
19
  test-2.js
@@ -18,51 +22,51 @@ testing bare fixture
18
22
  ✔ test2
19
23
  `
20
24
 
21
- it('should run in page', async () => {
22
- const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-async')
23
- assert.strictEqual(code, 0, 'exited with zero exit code')
24
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
25
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
26
- assert.ok(stdout.includes('Running bare-async page tests with Puppeteer'), 'stdout contains expected output for running in page')
27
- })
25
+ it('should run in page', async () => {
26
+ const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async')
27
+ assert.strictEqual(code, 0, 'exited with zero exit code')
28
+ const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
29
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
30
+ assert.ok(stdout.includes('Running bare-async page tests with Puppeteer'), 'stdout contains expected output for running in page')
31
+ })
28
32
 
29
- it('should run in worker', async () => {
30
- const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-async --worker --page=false')
31
- assert.strictEqual(code, 0, 'exited with zero exit code')
32
- const expected = expectedTemplate.replace(/WORKER/, 'in worker')
33
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
34
- assert.ok(stdout.includes('Running bare-async worker tests with Puppeteer'), 'stdout contains expected output for running in page')
35
- })
33
+ it('should run in worker', async () => {
34
+ const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --page=false')
35
+ assert.strictEqual(code, 0, 'exited with zero exit code')
36
+ const expected = expectedTemplate.replace(/WORKER/, 'in worker')
37
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
38
+ assert.ok(stdout.includes('Running bare-async worker tests with Puppeteer'), 'stdout contains expected output for running in page')
39
+ })
36
40
 
37
- it('should run in serviceworker', async () => {
38
- const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-async --serviceworker --page=false')
39
- assert.strictEqual(code, 0, 'exited with zero exit code')
40
- const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
41
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
42
- assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
43
- })
41
+ it('should run in serviceworker', async () => {
42
+ const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async --serviceworker --page=false')
43
+ assert.strictEqual(code, 0, 'exited with zero exit code')
44
+ const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
45
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
46
+ assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
47
+ })
44
48
 
45
- it('should run in page, worker and serviceworker', async () => {
46
- const { stdout, code } = await runCli(bareSyncFixture, '--runner=bare-async --worker --serviceworker')
47
- assert.strictEqual(code, 0, 'exited with zero exit code')
49
+ it('should run in page, worker and serviceworker', async () => {
50
+ const { stdout, code } = await runCli(bareAsyncFixture, '--runner=bare-async --worker --serviceworker')
51
+ assert.strictEqual(code, 0, 'exited with zero exit code')
48
52
 
49
- let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
50
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
51
- assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
53
+ let expected = expectedTemplate.replace(/WORKER/, 'not in worker')
54
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
55
+ assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
52
56
 
53
- expected = expectedTemplate.replace(/WORKER/, 'in worker')
54
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
55
- assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
57
+ expected = expectedTemplate.replace(/WORKER/, 'in worker')
58
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
59
+ assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
56
60
 
57
- expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
58
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
59
- assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
61
+ expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
62
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
63
+ assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in page')
64
+ })
60
65
  })
61
- })
62
66
 
63
- describe('failing bare-async', function () {
64
- this.timeout(20000)
65
- const expectedTemplate = `
67
+ describe(`failing bare-async (${type})`, function () {
68
+ this.timeout(20000)
69
+ const expectedTemplate = `
66
70
  testing is WORKER
67
71
  ✔ test-1.js
68
72
  test-2.js
@@ -70,49 +74,50 @@ testing bare fixture
70
74
  ✔ test1
71
75
  ✘ test2
72
76
  `
73
- const expectedStderr = 'AssertionError: \'nope\' undefined \'faily mcfailface\''
74
-
75
- it('should fail in page', async () => {
76
- let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-async')
77
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
78
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
79
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
80
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
81
- assert.ok(stdout.includes('Running bare-async page tests with Puppeteer'), 'stdout contains expected output for running in worker')
82
- assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
83
- })
77
+ const expectedStderr = 'AssertionError: faily mcfailface'
84
78
 
85
- it('should fail in worker', async () => {
86
- let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-async --worker --page=false')
87
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
88
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
89
- const expected = expectedTemplate.replace(/WORKER/, 'in worker')
90
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
91
- assert.ok(stdout.includes('Running bare-async worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
92
- assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
93
- })
79
+ it('should fail in page', async () => {
80
+ let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async')
81
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
82
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
83
+ const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
84
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
85
+ assert.ok(stdout.includes('Running bare-async page tests with Puppeteer'), 'stdout contains expected output for running in worker')
86
+ assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
87
+ })
94
88
 
95
- it('should fail in serviceworker', async () => {
96
- let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-async --serviceworker --page=false')
97
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
98
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
99
- const expected = expectedTemplate.replace(/WORKER/, 'in serviceworker')
100
- assert.ok(stdout.includes(expected), 'stdout contains expected test output')
101
- assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
102
- assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
103
- })
89
+ it('should fail in worker', async () => {
90
+ let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --worker --page=false')
91
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
92
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
93
+ const expected = expectedTemplate.replace(/WORKER/, 'in worker')
94
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
95
+ assert.ok(stdout.includes('Running bare-async worker tests with Puppeteer'), 'stdout contains expected output for running in worker')
96
+ assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
97
+ })
98
+
99
+ it('should fail in serviceworker', async () => {
100
+ let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --serviceworker --page=false')
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/, 'in serviceworker')
104
+ assert.ok(stdout.includes(expected), 'stdout contains expected test output')
105
+ assert.ok(stdout.includes('Running bare-async serviceworker tests with Puppeteer'), 'stdout contains expected output for running in worker')
106
+ assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
107
+ })
104
108
 
105
- it('should fail in page and not run in worker', async () => {
106
- let { stdout, stderr, code } = await runCli(bareSyncFailureFixture, '--runner=bare-async --worker')
107
- assert.strictEqual(code, 1, 'exited with non-zero exit code')
108
- stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
109
- const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
110
- let found = stdout.indexOf(expected)
111
- assert.ok(found > -1, 'stdout contains expected test output')
112
- found = stdout.indexOf(expected, found + 1)
113
- assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
114
- assert.ok(stdout.includes('Running bare-async page tests with Puppeteer'), 'stdout contains expected output for running in page')
115
- assert.ok(!stdout.includes('Running bare-async worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
116
- assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
109
+ it('should fail in page and not run in worker', async () => {
110
+ let { stdout, stderr, code } = await runCli(bareAsyncFailureFixture, '--runner=bare-async --worker')
111
+ assert.strictEqual(code, 1, 'exited with non-zero exit code')
112
+ stdout = stdout.replace(/^ +at .*\n/gm, '') // stack traces
113
+ const expected = expectedTemplate.replace(/WORKER/, 'not in worker')
114
+ let found = stdout.indexOf(expected)
115
+ assert.ok(found > -1, 'stdout contains expected test output')
116
+ found = stdout.indexOf(expected, found + 1)
117
+ assert.ok(found === -1, 'stdout doesn\'t contain second instance of expected test output')
118
+ assert.ok(stdout.includes('Running bare-async page tests with Puppeteer'), 'stdout contains expected output for running in page')
119
+ assert.ok(!stdout.includes('Running bare-async worker tests with Puppeteer'), 'stdout doesn\'t contain expected output for running in worker')
120
+ assert.ok(stderr.includes(expectedStderr), 'stderr contains expected output')
121
+ })
117
122
  })
118
- })
123
+ }