question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ava is reading .babelrc when given an explicit configuration

See original GitHub issue

Test Source

git clone git@github.com:gajus/ava-issue-1146.git
cd ./ava-issue-1146
npm install
ava --verbose ./test/EventEmitter/\#off.js

Error Message & Stack Trace

ava --verbose ./test/EventEmitter/\#off.js

/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-core/lib/transformation/file/options/option-manager.js:176
          throw new ReferenceError(messages.get("pluginUnknown", plugin, loc, i, dirname));
          ^

ReferenceError: Unknown plugin "test" specified in "/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/.babelrc" at 0, attempted to resolve relative to "/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146"
    at /Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-core/lib/transformation/file/options/option-manager.js:176:17
    at Array.map (native)
    at Function.normalisePlugins (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-core/lib/transformation/file/options/option-manager.js:154:20)
    at OptionManager.mergeOptions (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:36)
    at OptionManager.init (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:12)
    at compile (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-register/lib/node.js:103:45)
    at loader (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-register/lib/node.js:144:14)
    at require.extensions.(anonymous function) (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/babel-register/lib/node.js:154:7)
    at extensions.(anonymous function) (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/require-precompiled/index.js:16:3)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/ava/lib/process-adapter.js:104:4)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/test/EventEmitter/#off.js:3:1)
    at Module._compile (module.js:573:32)
    at extensions.(anonymous function) (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/require-precompiled/index.js:13:11)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/ava/lib/process-adapter.js:104:4)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/gajuskuizinas/Documents/dev/mailonline/ava-issue-1146/node_modules/ava/lib/test-worker.js:33:1)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.runMain (module.js:607:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3
  ✖ test/EventEmitter/#off.js exited with a non-zero exit code: 1

  0 tests passed [10:54:11]
  1 uncaught exception

Config

Copy the relevant section from package.json:

{
  "ava": {
    "babel": {
      "plugins": [
        "transform-es2015-modules-commonjs",
        "transform-flow-strip-types"
      ]
    },
    "require": [
      "babel-register"
    ]
  },
  "devDependencies": {
    "ava": "^0.17.0",
    "babel-cli": "^6.18.0",
    "babel-plugin-transform-es2015-modules-commonjs": "^6.18.0",
    "babel-plugin-transform-flow-strip-types": "^6.18.0",
    "babel-register": "^6.18.0",
    "sinon": "^1.17.6"
  },
  "private": true
}

Command-Line Arguments

Copy your npm build scripts or the ava command used:

ava --verbose ./test/EventEmitter/\#off.js

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.1.0
darwin 16.1.0
0.17.0
4.0.2

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8

github_iconTop GitHub Comments

7reactions
Wildhoneycommented, Jan 19, 2017

@gajus thanks.

For others reading this issue, I implemented it the following way.

With my .babelrc file I specified two separate env objects — one that satisfies Rollup and one that satisfies AVA:

{
  "env": {
    "build": {
      "presets": [
        "stage-3",
        ["es2015", { "modules": false }]
      ]
    },
    "test": {
      "presets": [
        "stage-3",
        "es2015"
      ]
    }
  }
}

I then had two separate commands for building and testing:

BABEL_ENV=build npm run build
BABEL_ENV=test npm test
0reactions
gajuscommented, Jan 19, 2017

I have ended up using different .babelrc settings for development, production and testing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ava-no-babel - npm Package Health Analysis - Snyk
Learn more about ava-no-babel: package health score, popularity, ... You'll have to configure the test script in your package.json to use ava (see...
Read more >
updated Ava configuration using babel - node.js
We have recently updated from ava 0.17.0 to version 2.4.0. The old configuration in the package.json no longer works and ava tests now...
Read more >
Removing Babel's Stage Presets
Moving forward with v7, we've decided it's best to stop publishing the Stage presets in Babel (e.g. `@babel/preset-stage-0`).
Read more >
jest | Yarn - Package Manager
Delightful JavaScript Testing. ava, babel, coverage, easy. readme. Jest. Delightful JavaScript Testing.
Read more >
babel-cli npm
For more information see the AVA recipe on how to configure Babel. Instead of running Babel directly from the command line we're going...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found