Add Jest testing framework
This commit is contained in:
21
__tests__/integration/page.spec.js
Normal file
21
__tests__/integration/page.spec.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { Builder } = require('selenium-webdriver');
|
||||
const chrome = require('selenium-webdriver/chrome');
|
||||
const chromeOptions = new chrome.Options();
|
||||
|
||||
let driver;
|
||||
|
||||
chromeOptions.addArguments('--headless', '--disable-gpu', '--no-sandbox');
|
||||
|
||||
beforeEach(async () => {
|
||||
const builder = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions);
|
||||
driver = builder.build();
|
||||
});
|
||||
|
||||
it('loads the page', async () => {
|
||||
await driver.get('http://localhost:8080');
|
||||
expect(await driver.getTitle()).toEqual('SVG Element Pan & Zoom Demo');
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await driver.quit();
|
||||
});
|
||||
21
__tests__/integration/setup.js
Normal file
21
__tests__/integration/setup.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
module.exports = async function (globalConfig, projectConfig) {
|
||||
console.info('\nSpawning server process...');
|
||||
const child = spawn('node', ['server.js']);
|
||||
|
||||
child.stdout.on('data', data => {
|
||||
console.log(`${data}`);
|
||||
});
|
||||
|
||||
globalThis.__INTEG_TEST_SERVER_PID__ = child.pid;
|
||||
|
||||
child.stderr.on('data', data => {
|
||||
const str = data.toString();
|
||||
console.log('[server]', str);
|
||||
|
||||
if (str.includes(projectConfig.globals.testServerUrl)) {
|
||||
setTimeout(resolve, 200);
|
||||
}
|
||||
});
|
||||
};
|
||||
4
__tests__/integration/teardown.js
Normal file
4
__tests__/integration/teardown.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = async function (globalConfig, projectConfig) {
|
||||
console.info('Stopping server.');
|
||||
process.kill(globalThis.__INTEG_TEST_SERVER_PID__);
|
||||
};
|
||||
Reference in New Issue
Block a user