-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add e2e tests #116
base: master
Are you sure you want to change the base?
Add e2e tests #116
Changes from 5 commits
ff0fa74
d83b56e
6693f58
a0d5cea
64f33fc
f5c8750
4ed1d56
bd036f3
4322c73
946f89b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
describe('About Route', () => { | ||
|
||
// Before each test | ||
beforeEach(() => { | ||
|
||
// Navigate to about component | ||
browser.get('http://localhost:3000/about'); | ||
}); | ||
|
||
// About component should be visible | ||
it('should be visible', () => { | ||
|
||
// Expect home component to be visible | ||
expect(element(by.tagName('about')).isDisplayed()).toBe(true); | ||
}); | ||
|
||
// Link to Home navigates to Home Component | ||
it('should navigate to Home if Home link clicked', () => { | ||
|
||
// Click navigation to Home route | ||
element(by.css('[ui-sref="home"]')) | ||
.click() | ||
.then(() => { | ||
|
||
// Expect Home Component to be visible | ||
expect(element(by.tagName('home')).isDisplayed()).toBe(true); | ||
|
||
// Expect About component to be not be present | ||
expect(element(by.tagName('about')).isPresent()).toBe(false); | ||
}) | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
describe('Home Route', () => { | ||
|
||
// Before each test | ||
beforeEach(() => { | ||
|
||
// Navigate to home component | ||
browser.get('http://localhost:3000'); | ||
}); | ||
|
||
|
||
// Home component should be visible | ||
it('should be visible', () => { | ||
|
||
// Expect home component to be visible | ||
expect(element(by.tagName('home')).isDisplayed()).toBe(true); | ||
}); | ||
|
||
// Link to About navigates to About Component | ||
it('should navigate to About if About link clicked', () => { | ||
|
||
// Click navigation to About route | ||
element(by.css('[ui-sref="about"]')) | ||
.click() | ||
.then(() => { | ||
|
||
// Expect About Component to be visible | ||
expect(element(by.tagName('about')).isDisplayed()).toBe(true); | ||
|
||
// Expect Home component to not be present | ||
expect(element(by.tagName('home')).isPresent()).toBe(false); | ||
}) | ||
}); | ||
|
||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
describe('<%= upCaseName %> Route', () => { | ||
|
||
// Before each test | ||
beforeEach(() => { | ||
|
||
// Navigate to <%= name %> component | ||
browser.get('http://localhost:3000/<%= name %>'); | ||
}); | ||
|
||
// <%= upCaseName %> component should be visible | ||
it('should be visible', () => { | ||
|
||
// Expect <%= upCaseName %> component to be visible | ||
expect(element(by.tagName('<%= name %>')).isDisplayed()).toBe(true); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
"mocha": "^2.3.0", | ||
"ng-annotate-loader": "0.0.10", | ||
"node-libs-browser": "^0.5.0", | ||
"protractor": "3.1.1", | ||
"raw-loader": "^0.5.1", | ||
"run-sequence": "^1.1.0", | ||
"style-loader": "^0.12.2", | ||
|
@@ -44,6 +45,10 @@ | |
"yargs": "^3.9.0" | ||
}, | ||
"scripts": { | ||
"preupdate-webdriver": "npm install", | ||
"update-webdriver": "webdriver-manager update", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe run it as |
||
"pree2e": "npm run update-webdriver", | ||
"e2e": "protractor protractor.conf.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we should move this to gulpfile, since it have all needed info about server host and port. |
||
"test": "karma start" | ||
}, | ||
"keywords": [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const webpackConfig = require('./webpack.config'); | ||
|
||
exports.config = { | ||
framework: "jasmine", | ||
baseUrl: `http://localhost:3000`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be introspected from the configs |
||
seleniumAddress: 'http://localhost:4444/wd/hub', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of using this, get protractor to auto download the selenium jar if it doesnt exist, and run its own server. Just remove this line, and presto, mission accomplished! |
||
specs: [ | ||
'client/**/**.e2e.js', | ||
'client/**/*.e2e.js' | ||
], | ||
jasmineNodeOpts: { | ||
showTiming: true, | ||
showColors: true, | ||
isVerbose: true, | ||
includeStackTrace: true, | ||
defaultTimeoutInterval: 400000 | ||
}, | ||
directConnect: true, | ||
capabilities: { | ||
'browserName': 'chrome', | ||
'chromeOptions': { | ||
'args': ['show-fps-counter=true'] | ||
} | ||
}, | ||
allScriptsTimeout: 30000, | ||
onPrepare: function () { | ||
require("babel-core/register")({ retainLines: true }); | ||
browser.ignoreSynchronization = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not best practice and should be avoided. If you want to ignore synchronization, do it on a test-by-test basis rather than app wide. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
urls called with browser get are relative to the base (you dont need to put localhost:3000 there)