forked from Strilanc/Quirk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch ci to github actions (Strilanc#459)
- Use puppeteer to run unit tests
- Loading branch information
Showing
7 changed files
with
3,850 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: ci | ||
on: [push] | ||
jobs: | ||
build-and-run-unit-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
- run: npm install | ||
- run: grunt build-test-page | ||
- run: node PuppeteerRunTests.js | ||
screenshot-circuit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
- run: npm install | ||
- run: npm run build | ||
- run: node PuppeteerScreenshotCircuit.js | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: screenshot | ||
path: screenshot.png |
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
const puppeteer = require('puppeteer'); | ||
|
||
(async () => { | ||
try { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
let caughtPageError = false; | ||
page.on('console', message => console.log(message.text())); | ||
page.on('pageerror', ({message}) => { | ||
caughtPageError = true; | ||
console.error("Page error bubbled into PuppeteerRunTests.js: " + message); | ||
}); | ||
|
||
const outDirUrl = 'file:///' + __dirname.split('\\').join('/') + '/out/'; | ||
await page.goto(outDirUrl + 'test.html#blocking'); | ||
await page.waitForSelector('#done', {timeout: 5 * 60 * 1000}); | ||
let anyFailures = await page.evaluate('__any_failures'); | ||
|
||
await browser.close(); | ||
if (anyFailures || caughtPageError) { | ||
process.exit(1); | ||
} | ||
} catch (ex) { | ||
console.error("Error bubbled up into PuppeteerRunTests.js: " + ex); | ||
process.exit(1); | ||
} | ||
})(); |
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,23 @@ | ||
const puppeteer = require('puppeteer'); | ||
|
||
(async () => { | ||
try { | ||
const browser = await puppeteer.launch(); | ||
const page = await browser.newPage(); | ||
let caughtPageError = false; | ||
page.on('console', message => console.log(message.text())); | ||
page.on('pageerror', ({message}) => { | ||
caughtPageError = true; | ||
console.error("Page error bubbled into PuppeteerSampleCircuit.js: " + message); | ||
}); | ||
const outDirUrl = 'file:///' + __dirname.split('\\').join('/') + '/out/'; | ||
const circuitJson = '{"cols":[["H"],["Bloch"],["Amps1"],[],["Density"],["•","X"],["Chance2"]]}'; | ||
await page.goto(outDirUrl + 'quirk.html#circuit=' + circuitJson); | ||
await page.waitForSelector('#loading-div', {visible: false, timeout: 5 * 1000}); | ||
await page.screenshot({path: 'screenshot.png'}); | ||
await browser.close(); | ||
} catch (ex) { | ||
console.error("Error bubbled up into PuppeteerSampleCircuit.js: " + ex); | ||
process.exit(1); | ||
} | ||
})(); |
Oops, something went wrong.