Skip to content

.babelrc settings cached inappropriately #872

Closed
@okcoker

Description

@okcoker

I was going through the code coverage docs noticed that adding some of the params to my .babelrc file, I would get the error below when running tests:

# I've replaced some of the exact folder/file paths
> NODE_PATH=$NODE_PATH:./src nyc ava | tap-diff

test.js:1
(function (exports, require, module, __filename, __dirname) { import hi from 'methods/hi';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:511:25)
    at Module.replacementCompile (/project/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at extensions.(anonymous function) (/project/node_modules/require-precompiled/index.js:13:11)
    at /project/node_modules/nyc/node_modules/append-transform/index.js:62:4
    at require.extensions.(anonymous function) (/project/node_modules/ava/lib/test-worker.js:91:3)
    at Object.<anonymous> (/project/node_modules/nyc/node_modules/append-transform/index.js:62:4)
    at Module.load (module.js:456:32)
    at tryModuleLoad (module.js:415:12)
    at Function.Module._load (module.js:407:3)
    at Module.require (module.js:466:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/project/node_modules/ava/lib/test-worker.js:95:1)
    at Module._compile (module.js:541:32)
    at Module.replacementCompile (/project/node_modules/nyc/node_modules/append-transform/index.js:58:13)
    at module.exports (/project/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)

  test/test.js exited with a non-zero exit code: 1
npm ERR! Test failed.  See above for more details.

The thing is, changing my .babelrc file back to a simple config below and re-testing, it still failed:

{
    "presets": ["es2015", "stage-0"],
}

Clearing the node_modules folder fixed things it seemed. I thought maybe it was related to this so I started looking for cache problems. I noticed when I clear out the node_modules/.cache/ava/ folder and re-test with my simple .babelrc file, the error goes away and tests run fine.

AVA portion of package.json

"ava": {
    "files": [
      "test/**/*-test.js"
    ],
    "source": [
      "src/**/*.js"
    ],
    "failFast": true,
    "tap": true,
    "require": [
      "babel-register"
    ],
    "babel": "inherit"
  }

Dependencies:

  "devDependencies": {
    "ava": "^0.15.0",
    "babel-cli": "^6.9.0",
    "babel-eslint": "^6.0.4",
    "babel-preset-es2015": "^6.9.0",
    "babel-preset-stage-0": "^6.5.0",
    "babel-register": "^6.9.0",
    "eslint": "^2.10.2",
    "eslint-plugin-promise": "^1.1.0",
    "mocha": "^2.5.2",
    "nodemon": "^1.9.2",
    "nyc": "^6.4.4",
    "rimraf": "^2.5.2",
    "sinon": "^1.17.4",
    "tap-diff": "^0.1.1"
  }

Version info:

$ npm -v
3.8.6
$ node -v
v6.1.0
$ ava --version
0.15.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcurrent functionality does not work as desired

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions