-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for zora and node flag
The node flag disables all the node injections similar to future webpack 5 behaviour.
- Loading branch information
1 parent
20d784a
commit 5a7b962
Showing
11 changed files
with
353 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
const { test } = require('zora'); | ||
|
||
test('a first sub test', (t) => { | ||
t.ok(true); | ||
|
||
t.test('inside', (t) => { | ||
t.ok(true); | ||
}); | ||
}); | ||
|
||
test('a first sub test', (t) => { | ||
t.ok(true); | ||
|
||
t.test('inside', (t) => { | ||
t.ok(false, 'oh no!'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const { test, only } = require('zora'); | ||
// import {test, only} from 'zora'; | ||
|
||
test('some grouped assertions', (t) => { | ||
t.ok(true, 'true is truthy'); | ||
t.equal('bar', 'bar', 'that both string are equivalent'); | ||
t.isNot({}, {}, 'those are not the same reference'); | ||
}); | ||
|
||
test('some grouped assertions', (t) => { | ||
t.ok(true, 'true is truthy'); | ||
|
||
t.test('a group inside another one', (t) => { | ||
t.equal('bar', 'bar', 'that both string are equivalent'); | ||
t.isNot({}, {}, 'those are not the same reference'); | ||
}); | ||
}); | ||
only('should run', (t) => { | ||
t.ok(true, 'I ran'); | ||
|
||
t.only('keep running', (t) => { | ||
t.only('keeeeeep running', (t) => { | ||
t.ok(true, ' I got there'); | ||
}); | ||
}); | ||
|
||
t.test('should not run', (t) => { | ||
t.fail('shouldn ot run'); | ||
}); | ||
}); | ||
only('should run but nothing inside', (t) => { | ||
t.test('will not run', (t) => { | ||
t.fail('should not run'); | ||
}); | ||
t.test('will not run', (t) => { | ||
t.fail('should not run'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* eslint-disable no-console */ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
const delay = require('delay'); | ||
const merge = require('webpack-merge'); | ||
const Runner = require('./runner'); | ||
const { addWorker, defaultWebpackConfig } = require('./utils'); | ||
|
||
const runZora = () => ` | ||
zora | ||
.report() | ||
.then((f) =>{ | ||
self.pwTestController.end(!self.zora.pass) | ||
}) | ||
`; | ||
|
||
const runZoraWorker = () => ` | ||
zora | ||
.report() | ||
.then((f) =>{ | ||
postMessage({ | ||
"pwRunEnded": true, | ||
"pwRunFailed": !self.zora.pass | ||
}) | ||
}) | ||
`; | ||
|
||
class ZoraRunner extends Runner { | ||
async runTests() { | ||
switch (this.options.mode) { | ||
case 'main': { | ||
await this.page.addScriptTag({ | ||
type: 'text/javascript', | ||
url: this.file | ||
}); | ||
await this.page.evaluate(runZora()); | ||
break; | ||
} | ||
case 'worker': { | ||
this.page.evaluate(addWorker(this.file)); | ||
const run = new Promise((resolve) => { | ||
this.page.on('workercreated', async (worker) => { | ||
await delay(1000); | ||
await worker.evaluate(runZoraWorker()); | ||
resolve(); | ||
}); | ||
}); | ||
|
||
await run; | ||
break; | ||
} | ||
default: | ||
console.error('mode not supported'); | ||
break; | ||
} | ||
} | ||
|
||
compiler() { | ||
const config = merge( | ||
defaultWebpackConfig(this.dir, this.env, this.options), | ||
{ | ||
entry: [ | ||
...this.options.files | ||
], | ||
resolve: { alias: { zora$: path.resolve(__dirname, 'setup-zora.js') } } | ||
} | ||
); | ||
|
||
return webpack(config); | ||
} | ||
} | ||
|
||
module.exports = ZoraRunner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const { createHarness } = require('zora/dist/bundle/index'); | ||
|
||
const harness = createHarness({ | ||
indent: process.env.INDENT === 'true', | ||
runOnly: process.env.RUN_ONLY === 'true' | ||
}); | ||
|
||
self.zora = harness; | ||
module.exports = harness; |
Oops, something went wrong.