message: make server run during tests too
diff: @@ -3,16 +3,49 @@ const path = require('path');
  module.exports = {
  name: '@cardstack/server',
  - serverMiddleware({ app, options }) {
  +
  + included(){
  + this._super.apply(this, arguments);
  + this.seedPath = path.join(path.dirname(this.project.configPath()), '..', 'cardstack', 'seeds');
  + },
  +
  + // The serverMiddleware hook is well-behaved and will wait for us to
  + // resolve a promise before moving on.
  + async serverMiddleware({ app, options }) {
  let { project, environment } = options;
  + let seedFile = path.join(this.seedPath, environment + '.js');
  + app.use('/cardstack', await this._middleware(seedFile, project.ui));
  + },
  - let seedPath = path.join(path.dirname(project.configPath()), '..', 'cardstack', 'seeds');
  - let seedFile = path.join(seedPath, environment + '.js');
  + // testemMiddleware will not wait for a promise, so we need to
  + // register something immediately. This is racy and makes it
  + // possible for early requests to fail -- if that turns out to have
  + // a practical effect we will need to queue requests here instead.
  + testemMiddleware(app) {
  + let seedFile = path.join(this.seedPath, 'test.js');
  + let handler;
  + this._middleware(seedFile).then(h => handler = h);
  + app.use('/cardstack', (req, res) => {
  + if (handler) {
  + handler(req, res);
  + } else {
  + res.status = 500;
  + res.send("Server not ready yet");
  + res.end();
  + }
  + });
  + },
  +
  + _middleware(seedFile, ui) {
  let seedModels = [];
  try {
  seedModels = require(seedFile);
  } catch (err) {
  - project.ui.writeWarnLine(`Unable to load your seed models (looking for ${seedFile})`);
  + if (ui) {
  + ui.writeWarnLine(`Unable to load your seed models (looking for ${seedFile})`);
  + } else {
  + process.stderr.write(`Unable to load your seed models (looking for ${seedFile})\n`);
  + }
  }
  // Without this node 7 swallows stack traces within the native
  @@ -22,7 +55,8 @@ module.exports = {
  });
  return makeServer(seedModels).then(server => {
  - app.use('/cardstack', server.callback());
  + return server.callback();
  });
  }
  +
  };
  