Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
fix: make FastBoot test more reliable
Browse files Browse the repository at this point in the history
I think that in some cases, the tests were being run before the Express
server had started. This should ensure that the express application
finished loading before Mocha begins executing the tests.
  • Loading branch information
alexlafroscia committed Jun 19, 2018
1 parent b96b65f commit 31ee07a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions fastboot-tests/helpers/server.js
@@ -1,7 +1,15 @@
var express = require('express');
var posts = require('./fixtures').POSTS;
var log = require('debug')('fastboot-tests:express-server');

var app = express();

app.use((req, res, next) => {
log(`${req.method}: ${req.originalUrl}`);

next();
});

app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET, OPTIONS');
Expand Down
4 changes: 2 additions & 2 deletions fastboot-tests/index-test.js
Expand Up @@ -9,8 +9,8 @@ var POSTS = require('./helpers/fixtures').POSTS;
describe('ember-ajax', function() {
setupTest('fastboot' /*, options */);

beforeEach(function() {
this.server = expressApp.listen(3000);
beforeEach(function(done) {
this.server = expressApp.listen(3000, done);
});

afterEach(function() {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -43,6 +43,7 @@
"@commitlint/travis-cli": "^7.0.0",
"broccoli-asset-rev": "^2.7.0",
"chai": "^4.1.2",
"debug": "^3.1.0",
"ember-cli": "~3.1.4",
"ember-cli-chai": "^0.5.0",
"ember-cli-dependency-checker": "^2.1.1",
Expand Down

0 comments on commit 31ee07a

Please sign in to comment.