-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-react-app.sh
89 lines (67 loc) · 2.57 KB
/
create-react-app.sh
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
#!/bin/bash
#––––– colours –––––#
LIGHTGREEN='\033[1;32m';
BLUE='\033[0;40m';
NOCOLOUR='\033[0m';
#–––––––––––––––––––#
echo "${BLUE}–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––${NOCOLOUR}"
### Read project name from stdin
echo "${LIGHTGREEN}Project name:${NOCOLOUR}";
read NAME;
### Run create react app npm package
echo "${LIGHTGREEN}Creating React application... this may take a while...${NOCOLOUR}";
npx create-react-app $NAME;
echo "${LIGHTGREEN}App created${NOCOLOUR}"
### Move into project and install dependencies
cd $NAME;
echo "${LIGHTGREEN}Installing dependencies... this may take a while...${NOCOLOUR}";
npm install;
echo "${LIGHTGREEN}Dependencies installed${NOCOLOUR}";
### Install and configure Enzyme and Nightwatch for testing
echo "${LIGHTGREEN}Configuring Enzyme and Nightwatch for testing${NOCOLOUR}";
npm install enzyme enzyme-adapter-react-16 chromedriver nightwatch selenium-server-standalone-jar --save-dev;
echo "import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });" > src/setupTests.js
echo 'const seleniumServer = require("selenium-server-standalone-jar");
const chromedriver = require("chromedriver");
module.exports = {
"src_folders": [
"src/integration"
],
"output_folder": "./reports",
"selenium": {
"start_process": true,
"server_path": seleniumServer.path,
"host": "127.0.0.1",
"port": 4444,
"cli_args": {
"webdriver.chrome.driver" : chromedriver.path
}
},
"test_settings" : {
"default" : {
"launch_url" : "http://localhost",
"selenium_port" : 4444,
"selenium_host" : "localhost",
"desiredCapabilities": {
"browserName": "chrome",
"javascriptEnabled": true,
"acceptSslCerts": true
}
}
}
}' > nightwatch.conf.js;
mkdir src/integration;
echo module.exports = "{
'Google': function (browser) {
browser
.url('https://www.google.co.uk/')
.waitForElementVisible('body', 2000)
.assert.title('Google')
.end();
}
};" > src/integration/exampleTest.js;
### Complete
echo "${BLUE} Done! ${NOCOLOUR}";
echo "${BLUE}–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––${NOCOLOUR}"