Custom Environments with TypeScript
See original GitHub issueI have checked the troubleshooting guide, it does not solve this issue.
Issue :
When creating a custom environment in TypeScript, Jest throws an error complaining about the TypeScript syntax. It appears that the custom environment is not being compiled.
Expected behavior :
FAIL tests/ticket-search/advanced-search.spec.ts
● Test suite failed to run
custom-environment.ts:9
async setup(): Promise<void> {
^
SyntaxError: Unexpected token ':'
at node_modules/jest-runner/build/runTest.js:259:7
Debug log:
N/A
jest.config.js
module.exports = {
preset: 'ts-jest',
testMatch: [
'<rootDir>/tests/**/*.spec.ts',
],
testRunner: 'jest-circus/runner',
testEnvironment: './scripts/custom-environment.ts',
moduleDirectories: [
'.',
'./node_modules',
'./utils',
'./interfaces',
],
...
};
Minimal repo
https://github.com/stangerjm/ts-jest-custom-env
npm install
npx jest
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
How to create Jest Custom Environment with Typescript?
Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Read more >TypeScript - Environment Setup - Tutorialspoint
Typescript can be built on a plethora of development environments like Visual Studio, Sublime Text 2, WebStorm/PHPStorm, Eclipse, Brackets, etc. Visual Studio ...
Read more >Parsing .env with TypeScript - DEV Community
env file and converting it into our own custom Config type that we want to use in the code. import path from "path";...
Read more >Setting up your TypeScript environment - ArcGIS Developers
This guide provides some basic steps for setting up your TypeScript development environment for use with the %ARCGISJS_SDK_PRODUCT_NAME%.
Read more >Configuring Jest
It is recommended to define the configuration in a dedicated JavaScript, TypeScript or JSON file. The file will be discovered automatically, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
it didn’t land in 26, but it will be in v27 (you can test it by installing
jest@next
)It will be supported in Jest 26: https://github.com/facebook/jest/pull/8751