-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnightwatch.config.js
67 lines (58 loc) · 1.99 KB
/
nightwatch.config.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
/* eslint-disable no-console */
const { resolve } = require('path')
const requireContext = require('require-context')
const { nightwatchConfig, getFiles } = require('picturebook')
/**
* CircleCI defines CI and all the CIRCLE_* env variables
* We additionally expose LOCAL_BRANCH as a way to customize the target url
*/
const { CI, CIRCLE_BRANCH, CIRCLE_BUILD_NUM, LOCAL_BRANCH } = process.env
const projectName = 'gymnast'
const branchName = CIRCLE_BRANCH || LOCAL_BRANCH
const isMaster = branchName === 'master'
const isCI = !!CI
/**
* The project is deployed at different URLS depending on the git branch:
* - master: https://gymnastjs.github.io/gymnast
* - branch: https://gymnastjs.github.io/gymnast/branch/${branch}
*/
const branchUrlSuffix = isMaster ? '' : `/branch/${branchName}`
// CI config is used when tests run on CircleCI
const ciConfig = {
/**
* Because SauceLabs uses all tests results to publish the browser support chart,
* we use 2 accounts:
* - For master, so it only contains all master tests
* - For development and branches, so tests can fail while developing without affecting the
* library browser support chart in the README
*/
username: process.env[`SAUCE_USERNAME${isMaster ? '_MASTER' : ''}`],
access_key: process.env[`SAUCE_ACCESS_KEY${isMaster ? '_MASTER' : ''}`],
desiredCapabilities: {
tags: [
CIRCLE_BRANCH,
isMaster ? projectName : `${projectName}-${CIRCLE_BRANCH}`,
],
build: CIRCLE_BUILD_NUM,
},
}
// local config is used for local development
const localConfig = {
username: process.env.SAUCE_USERNAME,
access_key: process.env.SAUCE_ACCESS_KEY,
desiredCapabilities: {
tags: [`${projectName}-dev`, 'local'],
build: 'dev',
},
}
module.exports = nightwatchConfig({
...(isCI ? ciConfig : localConfig),
files: getFiles({
baseUrl: `https://gymnastjs.github.io/gymnast${branchUrlSuffix}`,
stories: requireContext(
resolve(__dirname, './storybook/stories'),
true,
/\.tsx/
),
}),
})