question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not working typescript import suggestion

See original GitHub issue

Bug

  • package version: 0.11.2
  • node version: v12.13.0
  • npm (or yarn) 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:open
  • Created 4 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

2reactions
xenoterracidecommented, Jan 6, 2020

disabling diagnostics seems to work, albeit sketchy. however nothing suggested/tried seems to work in intellij except for the direct import

1reaction
abalhiercommented, Apr 2, 2020

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 :

ts-jest': {
      diagnostics: true,
      tsConfig: './tsconfig.json',
    }
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found