UNPKG

3.56 kBJavaScriptView Raw
1/*jshint jasmine: true, node: true */
2'use strict';
3
4const fs = require('fs-extra');
5const path = require('path');
6const merge = require('../../utils/merge');
7const SpecReporter = require('jasmine-spec-reporter').SpecReporter;
8
9const common = require('../../e2e/shared/common');
10const commonConfig = require('./protractor.conf');
11
12let config = {
13 specs: [
14 path.join(process.cwd(), 'e2e', '**', '*.e2e-spec.js')
15 ],
16 jasmineNodeOpts: {
17 defaultTimeoutInterval: 480000 // git clone, npm install, and skyux build can be slow
18 },
19 onPrepare: () => {
20 jasmine.getEnv().addReporter(new SpecReporter());
21
22 return new Promise((resolve, reject) => {
23
24 if (fs.existsSync(common.tmp) && !process.argv.includes('--clean')) {
25
26 console.log('');
27 console.log('*********');
28 console.log('Running fast e2e tests');
29 console.log(`Delete ${common.tmp} to have the install steps run.`);
30 console.log('*********');
31 console.log('');
32
33 resolve();
34
35 } else {
36
37 const url = 'https://github.com/blackbaud/skyux-sdk-template';
38 const branch = 'master';
39
40 console.log('Running command using full install.');
41 common.rimrafPromise(common.tmp)
42 .then(() => common.exec(`git`, [
43 `clone`,
44 `-b`,
45 branch,
46 `--single-branch`,
47 url,
48 common.tmp
49 ]))
50 .then(() => {
51
52 // This method attempts to take what would be installed from builder in to the SPA.
53 // It was the only reliable way I could convince NPM to install everything needed.
54 const spaPkgPath = path.resolve(common.tmp, 'package.json');
55 const spaPkgJson = fs.readJsonSync(spaPkgPath);
56
57 const builderPkgPath = path.resolve('package.json');
58 const builderPkgJson = fs.readJsonSync(builderPkgPath);
59
60 Object.keys(builderPkgJson.dependencies).forEach(dep => {
61 spaPkgJson.dependencies[dep] = builderPkgJson.dependencies[dep];
62 });
63
64 // Remove any installed versions of Builder.
65 delete spaPkgJson.devDependencies['@skyux-sdk/builder'];
66
67 fs.writeJsonSync(spaPkgPath, spaPkgJson, { spaces: 2 });
68 })
69 .then(() => common.exec(`npm`, [`i`], common.cwdOpts))
70 .then(() => {
71 // Copy builder's local source to node_modules.
72 const files = [
73 'cli',
74 'config',
75 'e2e',
76 'lib',
77 'loader',
78 'plugin',
79 'runtime',
80 'src',
81 'ssl',
82 'utils',
83 'index.js',
84 'package.json',
85 'skyuxconfig.json',
86 'tsconfig.json',
87 'tslint.json'
88 ];
89
90 files.forEach(file => {
91 fs.copySync(
92 file,
93 path.resolve(
94 common.tmp,
95 `node_modules/@skyux-sdk/builder/${file}`
96 )
97 );
98 });
99 })
100 .then(resolve)
101 .catch(reject);
102
103 }
104 });
105 },
106
107 // Catch any rogue servers
108 onComplete: () => common.afterAll
109};
110
111// In CI, use firefox
112if (process.env.TRAVIS) {
113 config.capabilities = {
114 browserName: 'chrome',
115 'chromeOptions': {
116 'args': [
117 '--disable-extensions',
118 '--ignore-certificate-errors',
119 '--no-sandbox'
120 ]
121 }
122 };
123}
124
125exports.config = merge(commonConfig.config, config);