Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

Import static json into test file

$
0
0

@zapalagrzegorz wrote:

Hey,

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 = data.name;
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:

config.js

export default
{
  // my json here...
}

then…

import config from '../config.js'

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

Thanks in advance

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4838

Trending Articles