This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
104 lines (78 loc) · 2.95 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const path = require('path');
const { spawn } = require('child_process');
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const del = require('del');
const PACKAGE_PARENT_DIR = path.join(__dirname, '../');
const PACKAGE_SEARCH_PATH = (process.env.NODE_PATH ? process.env.NODE_PATH + path.delimiter : '') + PACKAGE_PARENT_DIR;
function clean () {
return del('lib');
}
function lint () {
return gulp
.src([
'src/**/*.js',
'test/**/*.js',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}
function build () {
return spawn('npx tsc -p src/tsconfig.json', { stdio: 'inherit', shell: true });
}
function ensureAuthCredentials () {
const ERROR_MESSAGES = require('./lib/templates/error-messages');
if (!process.env.BROWSERSTACK_USERNAME || !process.env.BROWSERSTACK_ACCESS_KEY)
throw new Error(ERROR_MESSAGES.BROWSERSTACK_AUTHENTICATION_FAILED());
}
function testMocha () {
ensureAuthCredentials();
// const mochaOpts = [
// '--ui', 'bdd',
// '--reporter', 'spec',
// '--timeout', typeof v8debug === 'undefined' ? 2000 : Infinity,
// 'test/mocha/**/*test.js'
// ];
// NOTE: we must add the parent of plugin directory to NODE_PATH, otherwise testcafe will not be able
// to find the plugin. So this function starts mocha with proper NODE_PATH.
process.env.NODE_PATH = PACKAGE_SEARCH_PATH;
return spawn('echo "Asd"', { stdio: 'inherit', shell: true });
}
function testMochaRest () {
process.env.BROWSERSTACK_USE_AUTOMATE = 0;
return testMocha();
}
function testMochaAutomate () {
process.env.BROWSERSTACK_USE_AUTOMATE = 1;
return testMocha();
}
function testTestcafe () {
ensureAuthCredentials();
// const testCafeOpts = [
// browsers,
// 'test/testcafe/**/*test.js',
// '-s', '.screenshots'
// ];
// NOTE: we must add the parent of plugin directory to NODE_PATH, otherwise testcafe will not be able
// to find the plugin. So this function starts testcafe with proper NODE_PATH.
process.env.NODE_PATH = PACKAGE_SEARCH_PATH;
return spawn('echo "asd"', { stdio: 'inherit', shell: true });
}
function testTestcafeRest () {
process.env.BROWSERSTACK_USE_AUTOMATE = '0';
return testTestcafe();
}
function testTestcafeAutomate () {
process.env.BROWSERSTACK_USE_AUTOMATE = '1';
return testTestcafe();
}
exports.clean = clean;
exports.lint = lint;
exports.build = gulp.parallel(gulp.series(clean, build), lint);
exports.testMochaRest = testMochaRest;
exports.testMochaAutomate = testMochaAutomate;
exports.testTestcafeRest = gulp.series(exports.build, testTestcafeRest);
exports.testTestcafeAutomate = gulp.series(exports.build, testTestcafeAutomate);
exports.test = gulp.series(exports.build, testMochaRest, testMochaAutomate, testTestcafeRest, testTestcafeAutomate);