Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It's not possible to use .ts setup/teardown file for global setup/teardown #420

Closed
asemidotsky opened this issue Jan 23, 2018 · 2 comments
Closed

Comments

@asemidotsky
Copy link

  • Issue

It's not possible to use .ts setup/teardown file for global setup/teardown.
Jest has globalSetup and globalTeardown options which you can use for global setup/teardown but with ts-jest you can not use .ts files for setup.

I have Jest configuration in package.json:

"jest": {
  "globals": {
    "ts-jest": {
      "tsConfigFile": "tsconfig.json"
    }
  },
  "moduleFileExtensions": ["ts","js"],
  "transform": {
    "^.+\\.(ts|tsx)$": "./node_modules/ts-jest/preprocessor.js"
  },
  "testMatch": [
    "**/tests/**/*.test.(ts|js)"
  ],
  "testEnvironment": "node"
}

As I understand with this configuration ts-jest perform in memory transpiling of the .ts files. I have outDir option in compilerOptions of my tsconfig.json, but nothing is written in that outDir and because I cann't use transpiled jest-config.js for use in globalSetup option.

  • Expected behavior

Set options in config like this:

globalSetup: "./jest-setup.ts",
globalTeardown: "./jest-teardown.ts"

My question about this at StackOverflow

@kulshekhar
Copy link
Owner

@asemidotsky there was a discussion in #411 on this. I'm not sure how this can be fixed in ts-jest which can only transpile code that Jest passes to it.

I'm closing this but if my understanding is incorrect, it can be reopened and re-looked at

@renatoalencar
Copy link

If you're here, take a look at this: #411 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants