Import static json into test file


Just starting with Ember.

Trying to mock some data with prepared JSON. It’s theoretically possible, according to SO to import json into JS with Babel using following syntax:

1.  import * as data from './example.json';
2.  word =;
3. console.log(word); // output 'testing'

But keep getting error:

Could not find module .../tests/acceptance/example.json imported from .../tests/acceptance/page-report-test

ps. Workaround works for me:

A simple workaround from S:


export default
  // my json here...


import config from '../config.js'

does not allow import of existing .json files, but does a job.

Thanks in advance

As a more robust solution to this problem I’d highly recommend using ember-cli-mirage. It supports both static (fixture) and dynamic data creation for tests and also supports making a full fake “backend” that can handle ajax requests and so on. It’s super easy to use and can really speed along test writing and even development and prototyping (you can use it in development mode too).

As to your original issue though as mentioned in the SO answers ES6 doesn’t really allow this so if you need to import fixture data I’d use the “workaround” by putting it in a js file that exports it.

1 Like