-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add basic test with puppeteer for the website
- Loading branch information
Showing
15 changed files
with
326 additions
and
74 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
Empty file.
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 |
---|---|---|
|
@@ -49,3 +49,4 @@ android/keystores/debug.keystore | |
# jest | ||
coverage/ | ||
example/dist/ | ||
__diff_output__ |
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
Binary file added
BIN
+334 KB
...apshots__/website-spec-js-website-should-launch-website-with-webpack-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,70 @@ | ||
/* @flow */ | ||
|
||
import path from 'path'; | ||
import child_process from 'child_process'; // eslint-disable-line camelcase | ||
import puppeteer from 'puppeteer'; // eslint-disable-line import/no-extraneous-dependencies | ||
|
||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000; // eslint-disable-line no-undef | ||
|
||
describe('website', () => { | ||
let server; | ||
let browser; | ||
let page; | ||
|
||
beforeAll(async () => { | ||
server = child_process.spawn('yarn', ['start'], { | ||
cwd: path.join(__dirname, '..'), | ||
}); | ||
|
||
await new Promise((resolve, reject) => { | ||
server.stdout.on('data', data => { | ||
if (data.toString().includes('webpack: Compiled successfully.')) { | ||
resolve(data); | ||
} | ||
}); | ||
|
||
server.stderr.on('data', data => { | ||
reject(data); | ||
}); | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
server.kill(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
browser = await puppeteer.launch(); | ||
page = await browser.newPage(); | ||
}); | ||
|
||
afterEach(async () => { | ||
browser.close(); | ||
}); | ||
|
||
it('should launch website with webpack', async () => { | ||
await page.setViewport({ width: 800, height: 3260 }); | ||
await page.goto('http://localhost:3000', { waitUntil: 'networkidle' }); | ||
|
||
const screenshot = await page.screenshot(); | ||
|
||
/* $FlowFixMe */ | ||
expect(screenshot).toMatchImageSnapshot(); | ||
}); | ||
|
||
it('should have babel preset configured', async done => { | ||
page.on('console', message => { | ||
if ( | ||
message.args.some(m => | ||
String(m).includes('Babel preset for Linaria is not configured') | ||
) | ||
) { | ||
done.fail('Babel preset is not configured'); | ||
} | ||
}); | ||
|
||
await page.goto('http://localhost:3000', { waitUntil: 'networkidle' }); | ||
|
||
done(); | ||
}); | ||
}); |
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
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
Oops, something went wrong.