简体   繁体   中英

ava + ts-node converting .spec.ts files into .ts

I am running ava with ts-node with the following config:

"ava": {
    "files": [
        "tests/**/*",
        "!test/exclude-files-in-this-directory",
        "!**/exclude-files-with-this-name.*"
    ],
    "failFast": true,
    "failWithoutAssertions": false,
    "extensions": [
        "spec.ts",
        "ts"
    ],
    "environmentVariables": {
        "NODE_ENV": "test"
    },
    "require": [
        "ts-node/register",
        "tsconfig-paths/register"
    ],
    "tap": false,
    "verbose": true
}

The problem is that .spec.ts files don't get recognized, as ts-node is doing some kind of conversion (I think) of the .spec.ts files into just .ts , which means that the extension with spec.ts is never matched.

Here's the output of the tests

  - graphql › stage-2 › workspace.ts › do later
  ✔ general › functions.ts › returns proper difference

The files are named workspace.spec.ts and functions.spec.ts

Is there anyway for ts-node to not drop the spec part?

ts-node should only kick in when AVA requires the test file. I can't immediately spot why this isn't working. Are those spec.ts files inside the tests directory?

PS NODE_ENV already defaults to test , and you don't need to disable tap either.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM