Skip to content

tests: include e2e smoke tests for all examples #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.DS_Store
.idea/
.vscode
npm-debug.log
package-lock.json
node_modules
platforms/
app/tns_modules/
e2e/reports
test-results.xml
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ matrix:
- "curl -u $SAUCE_USER:$SAUCE_KEY -X POST -H 'Content-Type: application/octet-stream' $ANDROID_SAUCE_STORAGE --data-binary @$ANDROID_PACKAGE_FOLDER/$ANDROID_PACKAGE"
- os: osx
env:
- BuildiOS="10.3"
- Xcode="8.3"
osx_image: xcode8.3
- BuildiOS="11"
- Xcode="9.3"
osx_image: xcode9.3
language: node_js
node_js: "8"
jdk: oraclejdk8
Expand All @@ -73,17 +73,15 @@ matrix:
script:
- npm install -g appium
- npm install
- appium &
- travis_retry npm run appium -- --runType=android23 --sauceLab=true --appPath=$ANDROID_PACKAGE
- travis_retry npm run ci.android --appPath $ANDROID_PACKAGE
- npm run deploy
- os: linux
env:
- iOS="10"
- iOS="11"
language: node_js
node_js: "8"
script:
- npm install -g appium
- npm install
- appium &
- travis_wait travis_retry npm run appium -- --runType=ios-simulator103iPhone6 --sauceLab=true --appPath=$IOS_PACKAGE
- travis_wait travis_retry npm run e2e.ios --appPath $IOS_PACKAGE
- npm run deploy
2 changes: 1 addition & 1 deletion app/elements/components/ActivityIndicator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
template: `
<StackLayout class="m-20">
<ActivityIndicator busy="true"/>
<ActivityIndicator busy="true" automationText="ActivityIndicator" />
</StackLayout>
`
};
2 changes: 1 addition & 1 deletion app/elements/components/DatePicker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
template: `
<StackLayout class="m-20">
<DatePicker/>
<DatePicker automationText="DatePicker" />
</StackLayout>
`
};
2 changes: 1 addition & 1 deletion app/elements/components/Image.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
template: `
<GridLayout rows="auto" class="m-20">
<Image src="res://icon" stretch="none"/>
<Image src="res://icon" stretch="none" automationText="Image" />
</GridLayout>
`
};
File renamed without changes.
10 changes: 10 additions & 0 deletions appium.capabilities.json → e2e/config/appium.capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,15 @@
"deviceName": "iPhone Simulator",
"bundleId": "org.nativescript.nativescriptvueuitests",
"app": ""
},
"sim.iPhone8.iOS11.3": {
"platformName": "iOS",
"platformVersion": "11.3",
"deviceName": "iPhone 8",
"appiumVersion": "1.8.1",
"bundleId": "org.nativescript.nativescriptvueuitests",
"noReset": true,
"fullReset": false,
"app": ""
}
}
4 changes: 4 additions & 0 deletions e2e/config/mocha.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--timeout 800000
--recursive e2e
--reporter mocha-multi
--reporter-options spec=-,mocha-junit-reporter=test-results.xml
Empty file added e2e/resources/.gitkeep
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions e2e/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const nsAppium = require("nativescript-dev-appium");

// In case you need the server to started programatically
// before("start server", async () => {
// await nsAppium.startServer();
// });

// after("stop server", async () => {
// await nsAppium.stopServer();
// });
91 changes: 91 additions & 0 deletions e2e/smoke.tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
const assert = require("chai").assert;
const nsAppium = require("nativescript-dev-appium");

let driver;
before("create driver", async () => {
driver = await nsAppium.createDriver();
});

afterEach(`navigate back to main page after test`, async () => {
await driver.navBack();
});

after('quit driver', async () => {
await driver.quit();
console.log('Buh-Bye...');
});

describe("components", async () => {
const components = [
'ActivityIndicator',
'Button',
'DatePicker',
'HtmlView',
'Image',
'Label',
'ListPicker',
'ListView',
'Progress',
'ScrollView',
'SearchBar',
'SegmentedBar',
'Slider',
'Switch',
'TabView',
'TextField',
'TextView',
'TimePicker',
'WebView',
];

for (let component of components) {
it(`load ${component}`, async () => {
await loadComponent(component);

const result = await driver.compareScreen(component, 10, 0.1);
assert.isTrue(result, "Image comparisson has failed!");

if (component === 'SearchBar' && driver.isAndroid) {
await driver.navBack();
}
});
};
});

describe("dialogs", async () => {
const dialogs = [
'ActionDialog',
'AlertDialog',
'ConfirmDialog',
'LoginDialog',
'PromptDialog',
];

for (let dialog of dialogs) {
it(`load ${dialog}`, async () => {
await loadComponent(dialog);

const result = await driver.compareScreen(dialog, 10, 0.1);

if (driver.isIOS) {
const button = dialog === "ActionDialog" ? "cancel" : "OK";
const dialogItem = await driver.findElementByTextIfExists(button, nsAppium.SearchOptions.contains);
if (dialogItem) {
await dialogItem.click();
} else {
console.error(`Could not find ${button} to dismiss the dialog!`);
}
} else {
await driver.navBack();
}
assert.isTrue(result, "Image comparisson has failed!");
});
};
});


const loadComponent = async (component) => {
const listItem = await driver.findElementByText(component);
await listItem.click();
await driver.findElementByTextIfExists(component, nsAppium.SearchOptions.contains);
};
104 changes: 0 additions & 104 deletions generate-screenshots.js

This file was deleted.

27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,33 @@
"nativescript": {
"id": "org.nativescript.nativescriptvueuitests",
"tns-ios": {
"version": "3.4.1"
"version": "4.2.0"
},
"tns-android": {
"version": "3.4.1"
"version": "4.2.0"
}
},
"dependencies": {
"appium": "^1.7.1",
"nativescript-dev-appium": "^3.1.0-2017-10-6-1",
"nativescript-vue": "^1.0.0",
"tns-core-modules": "~3.4.0",
"yargs": "^9.0.1"
"tns-core-modules": "~4.2.0"
},
"scripts": {
"appium": "node generate-screenshots.js",
"android.build": "tns build android",
"android.screenshots": "npm run appium -- --runType=android23",
"ci.android.screenshots": "npm run appium -- --runType=android23 --sauceLab=true",
"ci.ios.screenshots": "npm run appium -- --runType=ios-simulator103iPhone6",
"ios.build": "tns build ios",
"deploy": "bash deploy.sh",
"e2e": "mocha --opts ./e2e/config/mocha.opts",
"ios.build": "tns build ios",
"ios.screenshots": "npm run appium -- --runType=ios-simulator103iPhone6"
"e2e.android": "npm run e2e -- --runType android23 --reuseDevice",
"e2e.ios": "npm run e2e -- --runType sim.iPhone8.iOS11.3 --reuseDevice",
"ci.android": "npm run e2e.android --sauceLab",
"ci.ios": "npm run e2e.ios --sauceLab"
},
"devDependencies": {
"babel-traverse": "6.26.0",
"babel-types": "6.26.0",
"babylon": "6.18.0",
"lazy": "1.0.11"
"lazy": "1.0.11",
"nativescript-dev-appium": "^4.0.5",
"chai": "^4.1.2",
"mocha": "^5.2.0"
}
}
}