Skip to content

Commit

Permalink
E2E testing: Remove @wdio/sync and update @wdio/* to the latest (#10990)
Browse files Browse the repository at this point in the history
* Remove @wdio/sync and update the rest of the @wdio packages

* Update the e2e tests to use async/await

* Add support for local e2e testing

* Update circleci to Node 16

* Update the min Node version to 12 and a a node check for e2e tests

* Fix the Node version check error
  • Loading branch information
jamarzka committed Jan 30, 2024
1 parent 1ec144f commit c161e0c
Show file tree
Hide file tree
Showing 22 changed files with 11,550 additions and 5,158 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ aliases:
- &environment
docker:
# specify the version you desire here
- image: circleci/node:12.16.1-browsers
- image: cimg/node:16.20-browsers
resource_class: xlarge
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ gulp test-coverage
gulp view-coverage
```

Local end-to-end testing can be done with:

```bash
gulp e2e-test --local
```

For Prebid.org members with access to BrowserStack, additional end-to-end testing can be done with:

```bash
Expand Down
61 changes: 41 additions & 20 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ function clean() {
.pipe(gulpClean());
}

function requireNodeVersion(version) {
return (done) => {
const [major] = process.versions.node.split('.');

if (major < version) {
throw new Error(`This task requires Node v${version}`)
}

done();
}
}

// Dependant task for building postbid. It escapes postbid-config file.
function escapePostbidConfig() {
gulp.src('./integrationExamples/postbid/oas/postbid-config.js')
Expand Down Expand Up @@ -293,7 +305,7 @@ function bundle(dev, moduleArr) {
// If --notest is given, it will immediately skip the test task (useful for developing changes with `gulp serve --notest`)

function testTaskMaker(options = {}) {
['watch', 'e2e', 'file', 'browserstack', 'notest'].forEach(opt => {
['watch', 'file', 'browserstack', 'notest'].forEach(opt => {
options[opt] = options.hasOwnProperty(opt) ? options[opt] : argv[opt];
})

Expand All @@ -302,22 +314,6 @@ function testTaskMaker(options = {}) {
return function test(done) {
if (options.notest) {
done();
} else if (options.e2e) {
const integ = startIntegServer();
startLocalServer();
runWebdriver(options)
.then(stdout => {
// kill fake server
integ.kill('SIGINT');
done();
process.exit(0);
})
.catch(err => {
// kill fake server
integ.kill('SIGINT');
done(new Error(`Tests failed with error: ${err}`));
process.exit(1);
});
} else {
runKarma(options, done)
}
Expand All @@ -326,10 +322,34 @@ function testTaskMaker(options = {}) {

const test = testTaskMaker();

function e2eTestTaskMaker() {
return function test(done) {
const integ = startIntegServer();
startLocalServer();
runWebdriver({})
.then(stdout => {
// kill fake server
integ.kill('SIGINT');
done();
process.exit(0);
})
.catch(err => {
// kill fake server
integ.kill('SIGINT');
done(new Error(`Tests failed with error: ${err}`));
process.exit(1);
});
}
}

function runWebdriver({file}) {
process.env.TEST_SERVER_HOST = argv.host || 'localhost';

let local = argv.local || false;

let wdioConfFile = local === true ? 'wdio.local.conf.js' : 'wdio.conf.js';
let wdioCmd = path.join(__dirname, 'node_modules/.bin/wdio');
let wdioConf = path.join(__dirname, 'wdio.conf.js');
let wdioConf = path.join(__dirname, wdioConfFile);
let wdioOpts;

if (file) {
Expand Down Expand Up @@ -486,8 +506,9 @@ gulp.task('serve-e2e-dev', gulp.series(clean, 'build-bundle-dev', gulp.parallel(

gulp.task('default', gulp.series(clean, 'build-bundle-prod'));

gulp.task('e2e-test-only', () => runWebdriver({file: argv.file}));
gulp.task('e2e-test', gulp.series(clean, 'build-bundle-prod', testTaskMaker({e2e: true})));
gulp.task('e2e-test-only', gulp.series(requireNodeVersion(16), () => runWebdriver({file: argv.file})));
gulp.task('e2e-test', gulp.series(requireNodeVersion(16), clean, 'build-bundle-prod', e2eTestTaskMaker()));

// other tasks
gulp.task(bundleToStdout);
gulp.task('bundle', gulpBundle.bind(null, false)); // used for just concatenating pre-built files with no build step
Expand Down
Loading

0 comments on commit c161e0c

Please sign in to comment.