-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
…e, run on any file ending with .e2e.js, run in verbose mode and use babel for es2015 compilation
…ent has a home at which to be tested. Still needs to be imported in components.js and provided a ui-sref link somewhere in order for route to work.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe run it as postinstall
script?
…h E2E tests and protractor configuration
…update and location for us. No longer need npm scripts either
How about now, guys? Removed extraneous code, added environment variables, using relative paths, and the developer experience is so much better. gulp e2e
npm e2e
|
|
||
|
||
gulp.task('e2e', ['protractor'], function() { | ||
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.
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?
let stopServer;
// ...
gulp.task('server', function (callback) {
const server = browsersync({...});
stopServer = () => {
server.exit();
callback();
};
});
// ...
stopServer();
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();
});
`
update on this ? Ive used most of this stuff and I can get the protractor to run properly, but as you say, when used with gulp it doesnt want to exit.. |
I currently working on getting rid of gulp completely. This will simplify stuff. |
Do we have a working version of the latest here? Curious... |
To run end to end tests:
E2E Test Generator
I've added a component e2e test file generator, and updated the component module generator with a default route of the component name. In order for the component to be tested, two tasks must still be accomplished.