-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathpretest.js
More file actions
46 lines (39 loc) · 1.21 KB
/
pretest.js
File metadata and controls
46 lines (39 loc) · 1.21 KB
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
var fs = require('fs');
var constants = require('./util/constants');
var mapboxAccessToken = process.env.MAPBOX_ACCESS_TOKEN;
if(!mapboxAccessToken) {
throw new Error([
'MAPBOX_ACCESS_TOKEN not found!!!',
'Please export your mapbox access token into and try again.'
].join('\n'));
}
// Create a credentials json file,
// to be required in jasmine test suites and test dashboard
var credentials = JSON.stringify({
MAPBOX_ACCESS_TOKEN: mapboxAccessToken
}, null, 2);
fs.writeFile(constants.pathToCredentials, credentials, function(err) {
if(err) throw err;
});
// Create a 'set plot config' file,
// to be included in the image test index
var setPlotConfig = [
'\'use strict\';',
'',
'/* global Plotly:false */',
'',
'Plotly.setPlotConfig({',
' mapboxAccessToken: \'' + mapboxAccessToken + '\'',
'});',
''
].join('\n');
fs.writeFile(constants.pathToSetPlotConfig, setPlotConfig, function(err) {
if(err) throw err;
});
// make artifact folders for image tests
if(!fs.existsSync(constants.pathToTestImagesDiff)) {
fs.mkdirSync(constants.pathToTestImagesDiff);
}
if(!fs.existsSync(constants.pathToTestImages)) {
fs.mkdirSync(constants.pathToTestImages);
}