-1

I have the following ava config in my package.json:

{
"ava": {
    "require": [
      "./tests/helpers/setup-browser-env.js",
      "./tests/helpers/module-stubber.js",
      "babel-register"
    ],
    "babel": {
      "presets": [
        "es2015",
        "stage-0",
        "react"
      ]
    },
    "failFast": true,
    "verbose": false,
    "no-cache": false,
    "concurrency": 5
  }
}

and I have the following project structure:

src
  index.jsx
  components
      input.jsx
tests
  index.test.js

index.jsx

import Input from './components/input';

console.log(Input);

input.jsx

import react from 'react';

export default () => <input></input>;

input.test.js

import app from '../src';
// ...

The problem is that ava is able to transpile my src/index.jsx file but it doesn't transpile input.jsx and I am seing an empty object logged in my console. It only works if I import the component using the .jsx extension like so: import Input from './component/input.jsx. I can't make it to work without specifying the extension.

Is this possible in AVA? In Webpack it is a simple config which handles these kinds of patterns.

Looking in the ava docs under the configuration section: https://github.com/avajs/ava#configuration I can't see any field which can help me. (also the config fields don't seem to be really detailed).

Any ideas?

Thanks in advance.

Andrei CACIO
  • 2,101
  • 15
  • 28

1 Answers1

1

babel-register is in charge of requiring input.jsx, not AVA. It's surprising that importing from ../src works, but importing input does not. I don't really have an answer for you though.

Mark Wubben
  • 3,329
  • 1
  • 19
  • 16