polendina 1.0.1 → 2.0.0-alpha2

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 (89) 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 +3 -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 +48 -22
  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/build/bundle.js +12790 -0
  61. package/test/fixtures/tape-esm/build/bundle.js.map +1 -0
  62. package/test/fixtures/tape-esm/build/common-run.js +108 -0
  63. package/test/fixtures/tape-esm/build/index.html +10 -0
  64. package/test/fixtures/tape-esm/build/page-run.js +46 -0
  65. package/test/fixtures/tape-esm/build/tape-run.js +39 -0
  66. package/test/fixtures/tape-esm/build/test-registry.js +6 -0
  67. package/test/fixtures/tape-esm/index.js +1 -0
  68. package/test/fixtures/tape-esm/package.json +19 -0
  69. package/test/fixtures/tape-esm/test.js +47 -0
  70. package/test/fixtures/tape-failure/build/bundle.js +12646 -0
  71. package/test/fixtures/tape-failure/build/bundle.js.map +1 -0
  72. package/test/fixtures/tape-failure/build/common-run.js +108 -0
  73. package/test/fixtures/tape-failure/build/index.html +10 -0
  74. package/test/fixtures/tape-failure/build/page-run.js +46 -0
  75. package/test/fixtures/tape-failure/build/tape-run.js +39 -0
  76. package/test/fixtures/tape-failure/build/test-registry.js +6 -0
  77. package/test/fixtures/tape-failure/package.json +1 -1
  78. package/test/fixtures/tape-failure-esm/package.json +19 -0
  79. package/test/fixtures/tape-failure-esm/test.js +29 -0
  80. package/test/fixtures/webpack-merge/package.json +4 -1
  81. package/test/fixtures/webpack-merge/test.js +3 -4
  82. package/test/fixtures/webpack-merge/webpack.config.js +3 -3
  83. package/test/test-bare-async.js +92 -87
  84. package/test/test-bare-sync.js +92 -87
  85. package/test/test-mocha.js +101 -96
  86. package/test/test-polendina-node.js +44 -38
  87. package/test/test-tape.js +99 -94
  88. package/test/test-webpack-merge.js +11 -9
  89. package/.github/workflows/main.yml +0 -21
@@ -0,0 +1,108 @@
1
+ /* globals WorkerGlobalScope ServiceWorkerGlobalScope clients */
2
+
3
+ import { registry } from './test-registry.js'
4
+
5
+ const inPage =
6
+ typeof window !== 'undefined' &&
7
+ window.location &&
8
+ typeof WorkerGlobalScope === 'undefined'
9
+ const inServiceWorker = !inPage &&
10
+ typeof ServiceWorkerGlobalScope !== 'undefined' &&
11
+ globalThis instanceof ServiceWorkerGlobalScope
12
+ const inWorker = !inPage && !inServiceWorker &&
13
+ typeof WorkerGlobalScope !== 'undefined' &&
14
+ globalThis instanceof WorkerGlobalScope
15
+ let _executionQueue = Promise.resolve()
16
+
17
+ export { registry }
18
+ export function executionQueue (fn) {
19
+ _executionQueue = _executionQueue.then(fn)
20
+ return _executionQueue
21
+ }
22
+
23
+ export const log = {
24
+ info: (...args) => {
25
+ executionQueue(() => globalThis.polendinaLog(['info'].concat(args)))
26
+ return executionQueue
27
+ },
28
+ // TODO
29
+ warn: (...args) => {
30
+ executionQueue(() => globalThis.polendinaLog(['warn'].concat(args)))
31
+ return executionQueue
32
+ },
33
+ // TODO
34
+ error: (...args) => {
35
+ executionQueue(() => globalThis.polendinaLog(['error'].concat(args)))
36
+ return executionQueue
37
+ }
38
+ }
39
+
40
+ function setupWorkerGlobals () {
41
+ globalThis.polendinaLog = async function (...args) {
42
+ globalThis.postMessage(['polendinaLog'].concat(args))
43
+ }
44
+
45
+ globalThis.polendinaWrite = async function (...args) {
46
+ globalThis.postMessage(['polendinaWrite'].concat(args))
47
+ }
48
+
49
+ globalThis.polendinaEnd = async function (...args) {
50
+ globalThis.postMessage(['polendinaEnd'].concat(args))
51
+ }
52
+ }
53
+
54
+ function setupServiceWorkerGlobals () {
55
+ async function _postMessage (msg) {
56
+ for (const client of await clients.matchAll()) {
57
+ client.postMessage(msg)
58
+ }
59
+ }
60
+
61
+ globalThis.polendinaLog = async function (...args) {
62
+ _postMessage(['polendinaLog'].concat(args))
63
+ }
64
+
65
+ globalThis.polendinaWrite = async function (...args) {
66
+ _postMessage(['polendinaWrite'].concat(args))
67
+ }
68
+
69
+ globalThis.polendinaEnd = async function (...args) {
70
+ _postMessage(['polendinaEnd'].concat(args))
71
+ }
72
+ }
73
+
74
+ function setupLogging () {
75
+ console.log = function (...args) {
76
+ try {
77
+ if (/BrowserStdout.*write/.test(new Error().stack)) {
78
+ // the BrowserStdout polyfill (Mocha ships with among others) that converts
79
+ // process.stdout.write() to console.log()
80
+ // so we strip out the extra \n that necessarily inserts
81
+ // args[0] = args[0].replace(/\n$/, '')
82
+ executionQueue(() => globalThis.polendinaWrite(args))
83
+ return
84
+ }
85
+ } catch (err) {}
86
+ log.info.apply(null, args)
87
+ }
88
+
89
+ // TODO: differentiate
90
+ console.warn = log.warn
91
+ console.error = log.error
92
+ }
93
+
94
+ export async function setup () {
95
+ if (inWorker) {
96
+ setupWorkerGlobals()
97
+ } else if (inServiceWorker) {
98
+ await new Promise((resolve, reject) => {
99
+ globalThis.addEventListener('activate', (event) => {
100
+ event.waitUntil(globalThis.clients.claim())
101
+ setupServiceWorkerGlobals()
102
+ resolve()
103
+ })
104
+ })
105
+ }
106
+
107
+ setupLogging()
108
+ }
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Tests</title>
6
+ </head>
7
+ <body>
8
+ <script src="page-run.js"></script>
9
+ </body>
10
+ </html>
@@ -0,0 +1,46 @@
1
+ /* globals self Worker */
2
+
3
+ // loaded as script file in index.html, determines how to load the bundle
4
+
5
+ const isWorkerMode = /mode=worker/.test(window.location.search)
6
+ const isServiceWorkerMode = /mode=serviceworker/.test(window.location.search)
7
+ const _consoleLog = console ? console.log : () => {}
8
+
9
+ function runPage () {
10
+ const script = document.createElement('script')
11
+ script.type = 'text/javascript'
12
+ script.src = 'bundle.js'
13
+ document.head.appendChild(script)
14
+ }
15
+
16
+ function onWorkerMessage (msg) {
17
+ if (!Array.isArray(msg.data)) {
18
+ return
19
+ }
20
+
21
+ if (!self[msg.data[0]]) {
22
+ _consoleLog.apply(console, msg.data)
23
+ } else {
24
+ self[msg.data[0]].apply(null, msg.data.slice(1))
25
+ }
26
+ }
27
+
28
+ function runWorker () {
29
+ const worker = new Worker('bundle.js')
30
+ worker.addEventListener('message', onWorkerMessage, false)
31
+ }
32
+
33
+ function runServiceWorker () {
34
+ navigator.serviceWorker.register('bundle.js', { scope: './' })
35
+ navigator.serviceWorker.addEventListener('message', onWorkerMessage, false)
36
+ }
37
+
38
+ window.addEventListener('load', () => {
39
+ if (isWorkerMode) {
40
+ runWorker()
41
+ } else if (isServiceWorkerMode) {
42
+ runServiceWorker()
43
+ } else {
44
+ runPage()
45
+ }
46
+ })
@@ -0,0 +1,39 @@
1
+ // in-browser setup and runner for Tape, at end of bundle
2
+
3
+ import tape from 'tape'
4
+ import { registry, setup, executionQueue } from './common-run.js'
5
+ import { Transform } from 'stream'
6
+
7
+ function runTape () {
8
+ let failures = 0
9
+
10
+ const stream = new Transform({
11
+ transform (chunk, encoding, callback) {
12
+ executionQueue(() => {
13
+ globalThis.polendinaWrite(chunk.toString())
14
+ .catch(callback)
15
+ .then(callback)
16
+ })
17
+ },
18
+
19
+ flush (callback) {
20
+ executionQueue(() => {
21
+ globalThis.polendinaEnd(failures)
22
+ .catch(callback)
23
+ .then(callback)
24
+ })
25
+ }
26
+ })
27
+
28
+ tape.getHarness({ stream })
29
+
30
+ tape.getHarness().onFailure((...args) => {
31
+ failures = 1
32
+ })
33
+
34
+ for (const mod of registry.tests) {
35
+ mod.load()
36
+ }
37
+ }
38
+
39
+ setup().then(runTape)
@@ -0,0 +1,6 @@
1
+ // see wrap-loader.js
2
+
3
+ export const registry = {
4
+ argv: null,
5
+ tests: []
6
+ }
@@ -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
+ }