babel-node is compiling test and failing

329 Views Asked by At

I can build and the code works and correctly excludes the tests using and can run the code with node:

babel src -s -d dist --extensions ".js,.ts,.tsx" --ignore '**/*.test.js' --ignore '**/test/*'

But trying to use babel-node seems to include the tests regardless:

babel-node --extensions '.js,.ts,.tsx' --ignore='src/**/*.test.js' src/index.js

Depending on the ignore pattern I can get different errors but errors inside a test file. eg. src/entity/authentication/authentication.test.js which babel should be ignoring.

I've tried a number of patters:

  • **/*.test.js
  • src/**/*.js
  • /src/**/*.js

I'm sure it something simple that I'm missing.

My babel config if its helpful:

{
"presets": [
  "@babel/preset-env",
  ["@babel/preset-typescript", {
    "isTSX": true,
    "allExtensions": true
  }]
],
"plugins": [
  "babel-plugin-transform-typescript-metadata",
  ["@babel/plugin-proposal-decorators", {"legacy": true}],
  "@babel/plugin-proposal-class-properties",
  "@babel/plugin-transform-runtime"
]

}

1

There are 1 best solutions below

0
pogson On

‍♂️Turns out it was not a babel issue at all it was a typeorm issue. https://github.com/typeorm/typeorm/issues/1654

"entities": [
  "src/entity/**/!(*.test)*.js"
]

Note to self: Always leave a project in working condition prior to taking a long break from it. :( Much time was wasted.