Skip to content

Ava does not transpile helpers! #1319

@grvcoelho

Description

@grvcoelho

Description

Ava should transpile helper files without requiring babel-register or any such a thing.

If the test files are inside a test folder, this works.

However: if the files are inside another folder (e.g: my-tests instead of test) or are inside a subfolder (e.g: test/unit) this does not work.

TLDR: If tests are inside a subfolder of test directory, ava DOES NOT TRANSPILE helper files

Test Source

/* FILE: test/unit/helpers/index.js */
import Promise from 'bluebird'

export const delay = (n) => Promise.delay(n)

/* ============================== */

/* FILE: test/unit/index.js */
import test from 'ava'
import { delay } from './helpers'

test('should return true', async (t) => {
  console.log('starting ===>', Date.now())
  await delay(2000)
  console.log('finishing ==>', Date.now())

  return true
})

Error Message & Stack Trace

~/H/l/ava (master) [n] ⋊> ./node_modules/.bin/ava test
/Users/grvcoelho/Hyperspace/labs/ava/test/unit/helpers/index.js:1
(function (exports, require, module, __filename, __dirname) { import Promise from 'bluebird'
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Module._extensions..js (module.js:580:10)
    at extensions.(anonymous function) (/Users/grvcoelho/Hyperspace/labs/ava/node_modules/require-precompiled/index.js:16:3)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/grvcoelho/Hyperspace/labs/ava/node_modules/ava/lib/process-adapter.js:105:4)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/grvcoelho/Hyperspace/labs/ava/test/unit/request.js:3:1)
    at Module._compile (module.js:571:32)
    at extensions.(anonymous function) (/Users/grvcoelho/Hyperspace/labs/ava/node_modules/require-precompiled/index.js:13:11)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/grvcoelho/Hyperspace/labs/ava/node_modules/ava/lib/process-adapter.js:105:4)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/grvcoelho/Hyperspace/labs/ava/node_modules/ava/lib/test-worker.js:33:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

  1 exception

  ✖ test/unit/request.js exited with a non-zero exit code: 1

Config

No configuration, which means no babel-register or such things

{
  "ava": {
  ...
  }
}

Command-Line Arguments

ava

Relevant Links

Repo with detailed instructions to reproduce the behavior: https://github.com/wasting-light/avajs-bug-report-x89

Environment

Tell us which operating system you are using, as well as which versions of Node.js, npm, and AVA. Run the following to get it quickly:

Node.js: v7.4.0
OS: darwin 16.4.0
Ava: 0.18.2
npm: 4.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcurrent functionality does not work as desiredscope:globbing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions