Search code examples
ember.jsember-app-kit

api-stubs failing when running tests with testem in ember-app-kit


I am trying to make use of the api-stubs provided in ember-app-kit for testing.

The stubs work correctly when I view the site in the browser, and when I run the tests by visting /tests in the browser.

However, when I run the tests from the command line with testem (by running grunt test:server) the tests fail as the stub data isn't returned.

You can find a minimal example demonstrating the problem here: https://github.com/tomclose/minimal_eak_test_stub_problem, created from the most recent version of ember-app-kit.

What am I doing wrong?


Solution

  • Because the testem stuff runs on port (7239 is it?) you a) can't run the apistub server ont he same port (already bound).

    Thus, you have to run the normal app (port 8000), let testem run on its own port.. and allow testem via the 'host' param in an adapter go find the right host:port combination to actually get data.

    As well, the addition of the cors() filter will make the :8000 test server willing to send data back to a "cross domain request" from something on port 7239

    The use of sinon is a different case (don't want to use apistub at all). I actually settled on NOT trying to use apistub for testing, but certainly the above approach works great.