I'm writing selenium test suites for NodeJS. Here's one sample test file:
var Sails = require('sails');
// create a variable to hold the instantiated sails server
var app;
var client;
// Global before hook
before(function(done) {
// Lift Sails and start the server
Sails.lift({
log: {
level: 'error'
},
environment: 'test',
port: 1338
}, function(err, sails) {
app = sails;
done(err, sails);
});
});
// Global after hook
after(function(done) {
app.lower(done);
});
beforeEach(function(done) {
client = require('webdriverjs').remote({desiredCapabilities:{browserName:'chrome'}});
client.init(done);
});
afterEach(function(done) {
client.end(done);
});
describe("Go to home page", function() {
it('should work', function(done) {
client
.url('http://localhost:1338/')
.pause(5000)
.call(done);
});
});
Currently:
- Starting each test file, it boots up the Sails server
- Finishing each test file, it shutdowns the Sails server
- Starting each test, it boots up the browser
- Finishing each test, it closes the browser
Therefore, if I have 10 selenium test files, it will boot/shutdown the Sails server 10 times. Is there any way to boot up the Sails server only once, running all test files, then shut it down?
I'm using Sails + Mocha + webdriverjs stack. Here's my Makefile config
test:
@./node_modules/.bin/mocha -u bdd -R spec --recursive --timeout 15000
.PHONY: test