Skip to content

Commit 4db9837

Browse files
Zdravkorigor789
Zdravko
authored andcommitted
pr checks in travis and sauce labs (nativescript-vue#481)
* fix: loading of css when using webpack bundle * chore: add custom webpack.config in order to use bundle during the build using current nativescript-dev-webpack plugin 0.21 * chore: add travis file to orchestrate the testing flow and tests * fix: ios build in travis
1 parent 8b51caa commit 4db9837

11 files changed

+293
-9
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ samples/package-lock.json
88
samples/platforms
99
samples/app/nativescript-vue.js
1010
samples/app/nativescript-vue.js.map
11+
samples/hooks/
12+
samples/mochawesome-report/
13+
samples/e2e/reports/
14+
test-results.xml
1115
dist/
1216
packages/nativescript-vue-template-compiler/index.js
1317
!docs/dist/

.travis.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
env:
2+
global:
3+
- ANDROID_PACKAGE_VUE='demo-ns-vue.apk'
4+
- ANDROID_PACKAGE_FOLDER_VUE=$TRAVIS_BUILD_DIR/samples/outputs
5+
- SAUCE_STORAGE="https://saucelabs.com/rest/v1/storage/$SAUCE_USER"
6+
- IOS_PACKAGE_VUE='demo-ns-vue.zip'
7+
- IOS_PACKAGE_FOLDER_VUE=$TRAVIS_BUILD_DIR/samples/outputs
8+
9+
git:
10+
depth: 1
11+
12+
branches:
13+
only:
14+
- master
15+
16+
matrix:
17+
include:
18+
- stage: "Unit Tests"
19+
language: node_js
20+
os: linux
21+
node_js: "8"
22+
script: npm i && npm run test
23+
- stage: "Build app"
24+
os: osx
25+
env:
26+
- WebpackiOS="12.0"
27+
- Type="VueJS"
28+
osx_image: xcode10.0
29+
language: node_js
30+
node_js: "8"
31+
jdk: oraclejdk8
32+
script:
33+
- npm i && npm run prepare:test:app
34+
- cd samples && npm i && tns build ios --bundle --env.uglify --copy-to "./outputs/demo-ns-vue.app"
35+
- cd $IOS_PACKAGE_FOLDER_VUE && zip -r $IOS_PACKAGE_VUE demo-ns-vue.app
36+
- "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $SAUCE_STORAGE/$IOS_PACKAGE_VUE?overwrite=true --data-binary @$IOS_PACKAGE_FOLDER_VUE/$IOS_PACKAGE_VUE"
37+
- language: android
38+
os: linux
39+
env:
40+
- WebpackAndroid="28"
41+
- Type="VueJS"
42+
jdk: oraclejdk8
43+
before_install: nvm install 8
44+
script:
45+
- npm i && npm run prepare:test:app
46+
- cd samples && npm i && tns build android --bundle --env.uglify --copy-to "./outputs/demo-ns-vue.apk"
47+
- "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $SAUCE_STORAGE/$ANDROID_PACKAGE_VUE?overwrite=true --data-binary @$ANDROID_PACKAGE_FOLDER_VUE/$ANDROID_PACKAGE_VUE"
48+
- stage: "UI Tests"
49+
env:
50+
- iOS="12.0"
51+
- Type="VueJS"
52+
language: node_js
53+
os: linux
54+
node_js: "8"
55+
script:
56+
- npm i -g appium
57+
- cd samples && npm i
58+
- travis_wait travis_retry npm run e2e -- --runType sim12iPhoneX --sauceLab --appPath $IOS_PACKAGE_VUE
59+
- os: linux
60+
env:
61+
- Android="24"
62+
- Type="VueJS"
63+
language: node_js
64+
os: linux
65+
node_js: "8"
66+
script:
67+
- npm i -g appium
68+
- cd samples && npm i
69+
- travis_wait travis_retry npm run e2e -- --runType android24.sauce --sauceLab --appPath $ANDROID_PACKAGE_VUE
70+
71+
android:
72+
components:
73+
- tools
74+
- platform-tools
75+
- build-tools-28.0.3
76+
- android-28
77+
- android-23
78+
- extra-android-m2repository
79+
80+
before_cache:
81+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
82+
83+
cache:
84+
directories:
85+
- .nvm
86+
- $HOME/.gradle/caches/
87+
- $HOME/.gradle/wrapper/
88+
89+
before_install:
90+
- sudo pip install --upgrade pip
91+
- sudo pip install six
92+
93+
install:
94+
- echo no | npm install -g nativescript
95+
- tns usage-reporting disable
96+
- tns error-reporting disable

samples/app/app-with-radsidedrawer-tabs-and-router.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const Home = {
2121

2222
const Tabs = {
2323
template: `
24-
<TabView
25-
androidTabsPosition="bottom"
24+
<GridLayout>
25+
<TabView androidTabsPosition="bottom"
2626
:selectedIndex="selectedTabIndex" >
2727
<TabViewItem title="Tab 1">
2828
<StackLayout>
@@ -34,7 +34,8 @@ const Tabs = {
3434
<Label text="You are on Tab 2" />
3535
</StackLayout>
3636
</TabViewItem>
37-
</TabView>`,
37+
</TabView>
38+
</GridLayout>`,
3839
data() {
3940
return {
4041
selectedTabIndex: 0,
@@ -103,7 +104,7 @@ new Vue({
103104
</RadSideDrawer>
104105
</Page>
105106
</Frame>
106-
`,
107+
`,
107108
data() {
108109
return {}
109110
},

samples/app/app.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@import '~nativescript-theme-core/css/core.light.css';
12
/* Your CSS goes here */
23

34
.even {

samples/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"main": "modals.js",
2+
"main": "app-with-radsidedrawer-tabs-and-router.js",
33
"name": "nativescript-template-tutorial",
44
"version": "1.0.1"
55
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"android23.local": {
3+
"platformName": "Android",
4+
"platformVersion": "6.0",
5+
"deviceName": "Emulator_Api23_Default",
6+
"avd": "Emulator_Api23_Default",
7+
"noReset": true
8+
},
9+
"android23": {
10+
"platformName": "Android",
11+
"platformVersion": "6.0",
12+
"deviceName": "Android Emulator",
13+
"appium-version": "1.7.1",
14+
"noReset": true
15+
},
16+
"android25": {
17+
"platformName": "Android",
18+
"platformVersion": "7.1",
19+
"deviceName": "Android GoogleAPI Emulator",
20+
"appium-version": "1.7.1",
21+
"noReset": true
22+
},
23+
"android24": {
24+
"platformName": "Android",
25+
"platformVersion": "7.0",
26+
"deviceName": "Android GoogleAPI Emulator",
27+
"appium-version": "1.9.1",
28+
"noReset": true,
29+
"lt": 60000,
30+
"newCommandTimeout": 720,
31+
"fullReset": false,
32+
"idleTimeout": 120,
33+
"automationName": "Appium"
34+
},
35+
"android24.sauce": {
36+
"platformName": "Android",
37+
"platformVersion": "7.0",
38+
"deviceName": "Android GoogleAPI Emulator",
39+
"lt": 60000,
40+
"newCommandTimeout": 720,
41+
"appiumVersion": "1.9.1",
42+
"noReset": true,
43+
"fullReset": false,
44+
"app": "",
45+
"idleTimeout": 120,
46+
"automationName": "Appium"
47+
},
48+
"sim11iPhone6": {
49+
"platformName": "iOS",
50+
"platformVersion": "11.0",
51+
"deviceName": "iPhone 6",
52+
"appium-version": "1.7.1",
53+
"app": ""
54+
},
55+
"sim103iPhone6": {
56+
"browserName": "",
57+
"appium-version": "1.7.1",
58+
"platformName": "iOS",
59+
"platformVersion": "10.3",
60+
"deviceName": "iPhone 6",
61+
"app": ""
62+
},
63+
"sim10iPhone6": {
64+
"platformName": "iOS",
65+
"platformVersion": "10.0",
66+
"deviceName": "iPhone 6",
67+
"appium-version": "1.7.1",
68+
"app": ""
69+
},
70+
"sim12iPhoneX":{
71+
"platformName": "iOS",
72+
"platformVersion": "12.0",
73+
"deviceName": "iPhone X",
74+
"appiumVersion": "1.9.1",
75+
"app": "",
76+
"noReset": true,
77+
"fullReset": false,
78+
"density": 3,
79+
"offsetPixels": 87,
80+
"idleTimeout": 120,
81+
"automationName": "Appium"
82+
}
83+
}

samples/e2e/config/mocha.opts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--timeout 200000
2+
--recursive e2e
3+
--reporter mocha-multi
4+
--reporter-options mochawesome=-,mocha-junit-reporter=test-results.xml
5+
--exit

samples/e2e/setup.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const nsAppium = require("nativescript-dev-appium");
2+
3+
before("start appium server", async () => {
4+
await nsAppium.startServer();
5+
});
6+
7+
after("stop appium server", async () => {
8+
await nsAppium.stopServer();
9+
});

samples/e2e/tests.e2e.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
const nsAppium = require("nativescript-dev-appium");
2+
const expect = require("chai").expect;
3+
const fs = require('fs');
4+
const addContext = require('mochawesome/addContext');
5+
const rimraf = require('rimraf');
6+
7+
describe("Vue", () => {
8+
let driver, isSauceRun;
9+
10+
before(async function () {
11+
driver = await nsAppium.createDriver();
12+
driver.defaultWaitTime = 15000;
13+
isSauceRun = driver.nsCapabilities.isSauceLab;
14+
let dir = "mochawesome-report";
15+
if (!fs.existsSync(dir)) {
16+
fs.mkdirSync(dir);
17+
}
18+
rimraf('mochawesome-report/*', function () { });
19+
});
20+
21+
after(async () => {
22+
if (isSauceRun) {
23+
driver.sessionId().then(function (sessionId) {
24+
console.log("Report https://saucelabs.com/beta/tests/" + sessionId);
25+
});
26+
}
27+
await driver.quit();
28+
console.log("Quit driver!");
29+
});
30+
31+
afterEach(async function () {
32+
if (this.currentTest.state && this.currentTest.state === "failed") {
33+
let png = await driver.logScreenshot(this.currentTest.title);
34+
fs.copyFile(png, './mochawesome-report/' + this.currentTest.title + '.png', function (err) {
35+
if (err) {
36+
throw err;
37+
}
38+
console.log('Screenshot saved.');
39+
});
40+
addContext(this, './' + this.currentTest.title + '.png');
41+
}
42+
});
43+
44+
describe("app-with-radsidedrawer-tabs-and-router", () => {
45+
it("Open sidedrawer", async () => {
46+
const home = await driver.findElementByText("Home");
47+
expect(home).to.exist;
48+
const menu = await driver.findElementByText("Menu");
49+
await menu.click();
50+
});
51+
52+
it("Open a menu item", async () => {
53+
const item = await driver.findElementByText("Hello1");
54+
await item.click();
55+
const detail = await driver.findElementByText("Hello world");
56+
expect(detail).to.exist;
57+
});
58+
59+
it("Open Tabs item", async () => {
60+
const menu = await driver.findElementByText("Menu");
61+
await menu.click();
62+
const item = await driver.findElementByText("Tabs");
63+
await item.click();
64+
const tab1 = await driver.findElementByText("You are on Tab 1");
65+
expect(tab1).to.exist;
66+
});
67+
68+
it("Click Tab 2", async () => {
69+
const tab = await driver.findElementByText("Tab 2");
70+
await tab.click();
71+
const tab2Content = await driver.findElementByText("You are on Tab 2");
72+
expect(tab2Content).to.exist;
73+
});
74+
});
75+
});

samples/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"version": "5.4.0"
1212
}
1313
},
14+
"scripts": {
15+
"e2e": "node ./node_modules/nativescript-dev-appium/check-dev-deps.js && mocha --opts ./e2e/config/mocha.opts"
16+
}
1417
"dependencies": {
1518
"@vue/devtools": "5.1.0",
1619
"nativescript-pager": "9.5.4",
@@ -23,6 +26,13 @@
2326
"vuex": "3.1.1"
2427
},
2528
"devDependencies": {
29+
"@types/chai": "~4.1.7",
30+
"@types/mocha": "~5.2.5",
31+
"@types/node": "~10.12.18",
32+
"mocha": "~5.2.0",
33+
"mocha-junit-reporter": "~1.18.0",
34+
"mocha-multi": "~1.0.1",
35+
"mochawesome": "^3.1.1",
2636
"@babel/core": "7.4.5",
2737
"@babel/preset-env": "7.4.5",
2838
"babel-loader": "8.0.6",

samples/webpack.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module.exports = env => {
3030
const projectRoot = __dirname;
3131
const nsVueRoot = resolve(projectRoot, '../');
3232

33-
// Default destination inside platforms/<platform>/...
33+
// Default destination inside platforms/<platform>/...
3434
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
3535
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";
3636

@@ -65,7 +65,8 @@ module.exports = env => {
6565
if (platform === "ios") {
6666
entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules.js";
6767
};
68-
console.log(`Bundling application for entryPath ${entryPath}...`);
68+
69+
console.log(`Bundling application for entryPath ${entryPath}...`);
6970

7071
let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist);
7172

@@ -81,7 +82,6 @@ module.exports = env => {
8182
],
8283
},
8384
target: nativescriptTarget,
84-
// target: nativeScriptVueTarget,
8585
entry: entries,
8686
output: {
8787
pathinfo: false,
@@ -277,7 +277,7 @@ module.exports = env => {
277277
);
278278
}
279279

280-
// Copy the native app resources to the out dir
280+
// Copy the native app resources to the out dir
281281
// only if doing a full build (tns run/build) and not previewing (tns preview)
282282
if (!externals || externals.length === 0) {
283283
config.plugins.push(new CopyWebpackPlugin([

0 commit comments

Comments
 (0)