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.
- package/.github/dependabot.yml +154 -0
- package/.github/workflows/test-and-release.yml +61 -0
- package/lib/log.js +8 -8
- package/lib/puppeteer.js +3 -5
- package/lib/webpack.config.js +15 -18
- package/lib/{wrap-loader.js → wrap-loader.cjs} +10 -7
- package/package.json +99 -18
- package/polendina-cli.js +7 -6
- package/polendina-node-cli.js +10 -6
- package/polendina.js +48 -22
- package/resources/bare-run.js +3 -3
- package/resources/bare.js +7 -5
- package/resources/common-run.js +23 -26
- package/resources/mocha-run.js +12 -12
- package/resources/tape-run.js +5 -5
- package/resources/test-registry.js +4 -1
- package/test/common.js +8 -8
- package/test/fixtures/bare-async/package.json +4 -1
- package/test/fixtures/bare-async/test-1.js +1 -1
- package/test/fixtures/bare-async/test-2.js +1 -1
- package/test/fixtures/bare-async-esm/index.js +3 -0
- package/test/fixtures/bare-async-esm/package.json +19 -0
- package/test/fixtures/bare-async-esm/test-1.js +16 -0
- package/test/fixtures/bare-async-esm/test-2.js +11 -0
- package/test/fixtures/bare-async-failure/package.json +4 -1
- package/test/fixtures/bare-async-failure/test-1.js +1 -1
- package/test/fixtures/bare-async-failure/test-2.js +2 -2
- package/test/fixtures/bare-async-failure-esm/index.js +3 -0
- package/test/fixtures/bare-async-failure-esm/package.json +19 -0
- package/test/fixtures/bare-async-failure-esm/test-1.js +16 -0
- package/test/fixtures/bare-async-failure-esm/test-2.js +11 -0
- package/test/fixtures/bare-sync/package.json +4 -1
- package/test/fixtures/bare-sync/test-1.js +1 -1
- package/test/fixtures/bare-sync/test-2.js +2 -1
- package/test/fixtures/bare-sync-esm/index.js +1 -0
- package/test/fixtures/bare-sync-esm/package.json +19 -0
- package/test/fixtures/bare-sync-esm/test-1.js +14 -0
- package/test/fixtures/bare-sync-esm/test-2.js +7 -0
- package/test/fixtures/bare-sync-failure/package.json +4 -1
- package/test/fixtures/bare-sync-failure/test-1.js +1 -1
- package/test/fixtures/bare-sync-failure/test-2.js +2 -2
- package/test/fixtures/bare-sync-failure-esm/index.js +1 -0
- package/test/fixtures/bare-sync-failure-esm/package.json +19 -0
- package/test/fixtures/bare-sync-failure-esm/test-1.js +14 -0
- package/test/fixtures/bare-sync-failure-esm/test-2.js +6 -0
- package/test/fixtures/mocha/package.json +2 -1
- package/test/fixtures/mocha/test-1.js +1 -1
- package/test/fixtures/mocha/test-2.js +1 -1
- package/test/fixtures/mocha/test-3.js +1 -1
- package/test/fixtures/mocha-esm/index.js +1 -0
- package/test/fixtures/mocha-esm/package.json +20 -0
- package/test/fixtures/mocha-esm/test-1.js +14 -0
- package/test/fixtures/mocha-esm/test-2.js +19 -0
- package/test/fixtures/mocha-esm/test-3.js +14 -0
- package/test/fixtures/mocha-failure/package.json +2 -1
- package/test/fixtures/mocha-failure/test.js +1 -1
- package/test/fixtures/mocha-failure-esm/package.json +20 -0
- package/test/fixtures/mocha-failure-esm/test.js +24 -0
- package/test/fixtures/tape/package.json +1 -1
- package/test/fixtures/tape-esm/build/bundle.js +12790 -0
- package/test/fixtures/tape-esm/build/bundle.js.map +1 -0
- package/test/fixtures/tape-esm/build/common-run.js +108 -0
- package/test/fixtures/tape-esm/build/index.html +10 -0
- package/test/fixtures/tape-esm/build/page-run.js +46 -0
- package/test/fixtures/tape-esm/build/tape-run.js +39 -0
- package/test/fixtures/tape-esm/build/test-registry.js +6 -0
- package/test/fixtures/tape-esm/index.js +1 -0
- package/test/fixtures/tape-esm/package.json +19 -0
- package/test/fixtures/tape-esm/test.js +47 -0
- package/test/fixtures/tape-failure/build/bundle.js +12646 -0
- package/test/fixtures/tape-failure/build/bundle.js.map +1 -0
- package/test/fixtures/tape-failure/build/common-run.js +108 -0
- package/test/fixtures/tape-failure/build/index.html +10 -0
- package/test/fixtures/tape-failure/build/page-run.js +46 -0
- package/test/fixtures/tape-failure/build/tape-run.js +39 -0
- package/test/fixtures/tape-failure/build/test-registry.js +6 -0
- package/test/fixtures/tape-failure/package.json +1 -1
- package/test/fixtures/tape-failure-esm/package.json +19 -0
- package/test/fixtures/tape-failure-esm/test.js +29 -0
- package/test/fixtures/webpack-merge/package.json +4 -1
- package/test/fixtures/webpack-merge/test.js +3 -4
- package/test/fixtures/webpack-merge/webpack.config.js +3 -3
- package/test/test-bare-async.js +92 -87
- package/test/test-bare-sync.js +92 -87
- package/test/test-mocha.js +101 -96
- package/test/test-polendina-node.js +44 -38
- package/test/test-tape.js +99 -94
- package/test/test-webpack-merge.js +11 -9
- 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,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,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
|
+
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const assert = require('
|
|
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(
|
|
7
|
-
console.log('
|
|
5
|
+
assert.strictEqual(WOOP, 'woop') // eslint-disable-line
|
|
6
|
+
console.log('WOOP is set')
|
package/test/test-bare-async.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/* globals describe it */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
8
|
-
const bareSyncFailureFixture = path.join(__dirname, 'fixtures/bare-async-failure')
|
|
8
|
+
const __dirname = fileURLToPath(path.dirname(import.meta.url))
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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(
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
}
|