mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-15 09:34:19 +08:00
fix(e2e): restore the events test fully
Also clean up the runner a bit
This commit is contained in:
@ -5,7 +5,7 @@ const glob = require('glob');
|
|||||||
const Mocha = require('mocha');
|
const Mocha = require('mocha');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webdriver = require('selenium-webdriver');
|
const webdriver = require('selenium-webdriver');
|
||||||
const argv = require('yargs').argv
|
const argv = require('yargs').argv;
|
||||||
|
|
||||||
const Page = require('./page');
|
const Page = require('./page');
|
||||||
const Snapshot = require('./snapshot');
|
const Snapshot = require('./snapshot');
|
||||||
@ -20,7 +20,11 @@ let folder = null;
|
|||||||
|
|
||||||
function startDevServer() {
|
function startDevServer() {
|
||||||
const server = require('@stencil/dev-server/dist'); // TODO: fix after stencil-dev-server PR #16 is merged
|
const server = require('@stencil/dev-server/dist'); // TODO: fix after stencil-dev-server PR #16 is merged
|
||||||
const cmdArgs = ['--config', path.join(__dirname, '../../stencil.config.js'), '--no-open'];
|
const cmdArgs = [
|
||||||
|
'--config',
|
||||||
|
path.join(__dirname, '../../stencil.config.js'),
|
||||||
|
'--no-open'
|
||||||
|
];
|
||||||
|
|
||||||
return server.run(cmdArgs);
|
return server.run(cmdArgs);
|
||||||
}
|
}
|
||||||
@ -61,11 +65,10 @@ function startDriver() {
|
|||||||
};
|
};
|
||||||
chromeCapabilities.set('chromeOptions', chromeOptions);
|
chromeCapabilities.set('chromeOptions', chromeOptions);
|
||||||
|
|
||||||
return new webdriver.Builder().withCapabilities(chromeCapabilities).forBrowser('chrome').build();
|
return new webdriver.Builder()
|
||||||
}
|
.withCapabilities(chromeCapabilities)
|
||||||
|
.forBrowser('chrome')
|
||||||
async function stopDriver() {
|
.build();
|
||||||
await driver.quit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function processCommandLine() {
|
function processCommandLine() {
|
||||||
@ -80,19 +83,14 @@ function processCommandLine() {
|
|||||||
|
|
||||||
function registerE2ETest(desc, tst) {
|
function registerE2ETest(desc, tst) {
|
||||||
// NOTE: Do not use an arrow function here because: https://mochajs.org/#arrow-functions
|
// NOTE: Do not use an arrow function here because: https://mochajs.org/#arrow-functions
|
||||||
it(desc, function(done) {
|
it(desc, async function() {
|
||||||
// const driver = startDriver();
|
await tst(driver, this);
|
||||||
(async function() {
|
if (takeScreenshots) {
|
||||||
await tst(driver, this);
|
await snapshot.takeScreenshot(driver, {
|
||||||
if (takeScreenshots) {
|
name: this.test.fullTitle().replace(/(^[\w-]+\/[\w-]+)/, '$1:'),
|
||||||
await snapshot.takeScreenshot(driver, {
|
specIndex: specIndex++
|
||||||
name: this.test.fullTitle().replace(/(^[\w-]+\/[\w-]+)/, '$1:'),
|
});
|
||||||
specIndex: specIndex++
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
// await driver.quit();
|
|
||||||
done();
|
|
||||||
})();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +122,7 @@ async function run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
devServer.close();
|
devServer.close();
|
||||||
stopDriver();
|
await driver.quit();
|
||||||
|
|
||||||
if (failures) {
|
if (failures) {
|
||||||
throw new Error(failures);
|
throw new Error(failures);
|
||||||
@ -170,7 +168,6 @@ function mochaLoadFiles(mocha) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function parseSemver(str) {
|
function parseSemver(str) {
|
||||||
return /(\d+)\.(\d+)\.(\d+)/
|
return /(\d+)\.(\d+)\.(\d+)/
|
||||||
.exec(str)
|
.exec(str)
|
||||||
@ -182,19 +179,22 @@ function validateNodeVersion(version) {
|
|||||||
const [major, minor] = parseSemver(version);
|
const [major, minor] = parseSemver(version);
|
||||||
|
|
||||||
if (major < 7 || (major === 7 && minor < 6)) {
|
if (major < 7 || (major === 7 && minor < 6)) {
|
||||||
throw new Error('Running the end-to-end tests requires Node version 7.6.0 or higher.');
|
throw new Error(
|
||||||
|
'Running the end-to-end tests requires Node version 7.6.0 or higher.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoke run() only if executed directly i.e. `node ./scripts/e2e`
|
// Invoke run() only if executed directly i.e. `node ./scripts/e2e`
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
validateNodeVersion(process.version);
|
validateNodeVersion(process.version);
|
||||||
run().then(() => {
|
run()
|
||||||
}).catch((err) => {
|
.then(() => {})
|
||||||
console.log(err);
|
.catch(err => {
|
||||||
// fail with non-zero status code
|
console.log(err);
|
||||||
process.exit(1);
|
// fail with non-zero status code
|
||||||
});
|
process.exit(1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -18,8 +18,7 @@ platforms.forEach(platform => {
|
|||||||
return page.navigate('#content');
|
return page.navigate('#content');
|
||||||
});
|
});
|
||||||
|
|
||||||
/*register('subscribers should receive event on or shortly after button click', async (driver, testContext) => {
|
register('subscribers should receive event on or shortly after button click', async (driver, testContext) => {
|
||||||
|
|
||||||
testContext.timeout(1000);
|
testContext.timeout(1000);
|
||||||
const page = new E2ETestPage(driver, platform);
|
const page = new E2ETestPage(driver, platform);
|
||||||
await wait(300);
|
await wait(300);
|
||||||
@ -38,7 +37,6 @@ platforms.forEach(platform => {
|
|||||||
const secretTwoText = await secretTwoElement.getText();
|
const secretTwoText = await secretTwoElement.getText();
|
||||||
expect(secretTwoText).to.equal('Burrito');
|
expect(secretTwoText).to.equal('Burrito');
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user