-
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
Open
samreaves
wants to merge
10
commits into
PatrickJS:master
Choose a base branch
from
samreaves:add-e2e-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add e2e tests #116
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ff0fa74
Added protractor dependency and end to end npm test scripts
samreaves d83b56e
Configured protractor to use Chrome, go to localhost:3000, use jasmin…
samreaves 6693f58
Added e2e tests for route components
samreaves a0d5cea
End to end test generator
samreaves 64f33fc
Proposed module change with route included so as to ensure the compon…
samreaves f5c8750
Removed ignoreSynchronization by default. Configured base URLs in bot…
samreaves 4ed1d56
Replaced default ChromeDriver with updated Selenium jar.
samreaves bd036f3
Moved e2e tests to gulp. Can't seem to stop the serve process for som…
samreaves 4322c73
Figured out how to stop server
samreaves 946f89b
Jar location no longer needed as gulp-protractor-angular handles the …
samreaves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/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); | ||
}) | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/'); | ||
}); | ||
|
||
|
||
// 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); | ||
}) | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('/<%= name %>'); | ||
}); | ||
|
||
// <%= upCaseName %> component should be visible | ||
it('should be visible', () => { | ||
|
||
// Expect <%= upCaseName %> component to be visible | ||
expect(element(by.tagName('<%= name %>')).isDisplayed()).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
exports.config = { | ||
framework: "jasmine", | ||
baseUrl: `http://localhost:${process.env.PORT || 3000}`, | ||
specs: [ | ||
'client/**/**.e2e.js', | ||
'client/**/*.e2e.js' | ||
], | ||
jasmineNodeOpts: { | ||
showTiming: true, | ||
showColors: true, | ||
isVerbose: true, | ||
includeStackTrace: true, | ||
defaultTimeoutInterval: 400000 | ||
}, | ||
capabilities: { | ||
'browserName': 'chrome', | ||
'chromeOptions': { | ||
'args': ['show-fps-counter=true'] | ||
} | ||
}, | ||
allScriptsTimeout: 30000, | ||
onPrepare: function () { | ||
require("babel-core/register")({ retainLines: true }); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is maybe not a good idea, but we could store server instance in gulpfile scope and then just stop it. But i think this is better than
process.exit
.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.
In the previous commit I have serve.exit() from the browser-sync API instead, and it doesn't stop the server. Exiting the process seemed to be the only option.
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.
It doesn't stop gulp task maybe?
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.
I think you're right. However with that implementation, protractor never starts. Probably because serve task is expecting to only proceed after the callback?
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.
Yah, you are right... so we need to run callback after server is ready.
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.
Unsure what I'm missing here. Everything finishes except for the process.
`
let stopServer;
// Setting up the test task
gulp.task('protractor', ['serve'], function(callback) {
gulp
.src(['example_spec.js'])
.pipe(gulpProtractorAngular({
'configFile': 'protractor.conf.js',
'debug': false,
'autoStartStopServer': true
}))
.on('error', function(e) {
console.log(e);
})
.on('end', callback);
});
gulp.task('e2e', ['protractor'], function(callback) {
//process.exit();
stopServer();
callback();
});
gulp.task('serve', function(callback) {
const config = require('./webpack.dev.config');
config.entry.app = [
// this modules required to make HRM working
// it responsible for all this webpack magic
'webpack-hot-middleware/client?reload=true',
// application entry point
paths.entry
];
var compiler = webpack(config);
const server = serve.init({
port: process.env.PORT || 3000,
open: false,
server: {baseDir: root},
middleware: [
historyApiFallback(),
webpackDevMiddelware(compiler, {
stats: {
colors: colorsSupported,
chunks: false,
modules: false
},
publicPath: config.output.publicPath
}),
webpachHotMiddelware(compiler)
]
});
stopServer = function() {
server.exit();
}
callback();
});
`