Not working typescript import suggestion
See original GitHub issueBug
package
version: 0.11.2node
version: v12.13.0npm
(oryarn
) version: 6.12.0
Relevant code or config
See steps.
What you did:
Following this guide: https://github.com/jest-community/jest-extended/issues/172
The global.d.ts
file:
import 'jest-extended';
The tsconfig.json
file:
{
"compilerOptions": {
"target": "es2018",
"module": "commonjs",
"outDir": "./lib",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true
},
"include": [
"src/**/*",
"./global.d.ts"
],
"exclude": ["test"]
}
The jest.config.js
file (using ts-jest):
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: {
'ts-jest': {
diagnostics: false,
},
},
};
What happened (please provide anything you think will help):
The function is still not found:
FAIL test/services/rides.test.ts
'rides' service
✓ registered the service (3ms)
✕ creates a ride (75ms)
✕ it complete a step (13ms)
● 'rides' service › creates a ride
TypeError: expect(...).toSatisfyAll is not a function
42 | expect(ride.currentStep).toBe(0);
43 | expect(ride.steps).toHaveLength(4);
> 44 | expect(ride.steps).toSatisfyAll((step) => step.doneAt === null)
| ^
45 | rideId = ride._id;
46 | });
47 |
Current workaround:
Adding import 'jest-extended';
directly on each test file I use the jest-extended solves the issue, but it’s cumbersome.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:5
Top Results From Across the Web
Auto Imports / Suggestions not working since adding typescript
React with typescript is suggesting the correct imports in all file types. Please navigate to the App.tsx file and the Test.js file to...
Read more >typescript auto imports not working macos - Stack Overflow
Here I am expecting to see a suggestion for an import for ImageRowsInitializer from the file called images-row.ts . images-row.ts export class ...
Read more >How to get JavaScript auto-import suggestions working in VS ...
As of 2018, VS Code treats all JS files as separate from one another. In order to tell it that your files are...
Read more >Auto-Import not resolving TypeScript source (not declarations ...
I am running "npm i –force @kabbage/angular" in my project, after which the node_modules/@kabbage and node_modules/@kabbage/angular directories contain the code ...
Read more >JavaScript Programming with Visual Studio Code
Working with JavaScript in Visual Studio Code ... If you choose one of these auto import suggestions, VS Code adds an import for...
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
disabling diagnostics seems to work, albeit sketchy. however nothing suggested/tried seems to work in intellij except for the direct import
I think you need to remove
"exclude": ["test"]
in your tsconfig.json, otherwise it won’t compile your tests with this config and without including global.d.ts You also may have to specify the tsConfig key in your jest config, like so :