-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
66 lines (51 loc) · 2.42 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* global require process */
const fs = require('node:fs');
const gulp = require('gulp');
const parseArgs = require('minimist');
const qunit = require('gulp-qunit-harness');
const spawn = require('child_process').spawn;
const testCafeBrowserTools = require('testcafe-browser-tools');
const args = parseArgs(process.argv.slice(2));
const NOT_DEBUG = !args.debug;
const LIB_PATH = 'lib';
const NO_SANDBOX_ARG = '--no-sandbox';
const QUNIT_SETTINGS = {
port: 2000,
crossDomainPort: 2001,
/* eslint-disable no-multi-spaces */
scripts: [
{ src: '/hammerhead.js', path: 'node_modules/testcafe-hammerhead/lib/client/hammerhead.js' },
{ src: '/core.js', path: 'node_modules/testcafe/lib/client/core/index.js' },
{ src: '/ui.js', path: 'node_modules/testcafe/lib/client/ui/index.js' },
{ src: '/automation.js', path: 'node_modules/testcafe/lib/client/automation/index.js' },
{ src: '/driver.js', path: 'node_modules/testcafe/lib/client/driver/index.js' },
{ src: '/before-test.js', path: 'test/utils/before-test.js' },
{ src: '/get-selector.js', path: 'test/utils/get-selector.js' },
{ src: '/selector-generator.js', path: 'lib/load-selector-generator.js' },
],
/* eslint-enable no-multi-spaces */
configApp: require('./test/utils/config-qunit-server-app'),
basePath: 'test/fixtures',
};
gulp.task('clear', () => {
return fs.promises.rm(LIB_PATH, { force: true, recursive: true });
});
gulp.task('build-run', () => {
return spawn('npx rollup -c --bundleConfigAsCjs', { shell: true, stdio: 'inherit' });
});
gulp.task('build', gulp.series('clear', 'build-run'));
gulp.task('test-run', async () => {
const browsers = await testCafeBrowserTools.getInstallations();
const browserName = args.browser || 'chrome';
const browserInfo = browsers[browserName];
const targetBrowsers = [{ browserInfo, browserName }];
const cliSettings = { browsers: targetBrowsers, timeout: 60 };
const settings = NOT_DEBUG && cliSettings;
const cliMode = NOT_DEBUG && { cliMode: true };
if (NOT_DEBUG && /edge|chrome/.test(browserName.toLowerCase()))
browserInfo.cmd += ` ${NO_SANDBOX_ARG}`;
return gulp
.src(['test/fixtures/**/*-test.js'])
.pipe(qunit(QUNIT_SETTINGS, settings, cliMode));
});
gulp.task('test', gulp.series('build', 'test-run'));