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.

TypeScript integration not working

See original GitHub issue

I am not sure what I am doing wrong since I following the documentation

// setupFiles

import { GlobalWithFetchMock } from 'jest-fetch-mock';

const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;

customGlobal.fetch = require('jest-fetch-mock');

customGlobal.fetchMock = customGlobal.fetch;

tests

afterEach(() => {
    fetchMock.resetMocks(); // Cannot find name 'fetchMock'
  });

it keeps saying Cannot find name 'fetchMock' TS2304

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
viT-1commented, Jan 27, 2020

just found another setup configuration (https://github.com/jefflau/jest-fetch-mock/issues/82#issuecomment-475067797):

in jest setup file: require('jest-fetch-mock').enableMocks();

in test:

import { FetchMock } from 'jest-fetch-mock';
const fetchMock = fetch as FetchMock;
2reactions
yordiscommented, Jan 24, 2020

Setup: https://github.com/straw-hat-team/javascript/blob/develop/packages/libraries/fetcher/test/setup-files.ts

import { GlobalWithFetchMock } from 'jest-fetch-mock';

const customGlobal: GlobalWithFetchMock = global as GlobalWithFetchMock;

customGlobal.fetch = require('jest-fetch-mock');

customGlobal.fetchMock = customGlobal.fetch;

Usage:

https://github.com/straw-hat-team/javascript/blob/e428d750c2223c70c362eccd5a31f1022783234c/packages/libraries/fetcher/test/index.test.ts#L15

https://github.com/straw-hat-team/javascript/blob/e428d750c2223c70c362eccd5a31f1022783234c/packages/libraries/fetcher/test/index.test.ts#L15

afterEach(() => {
    fetchMock.resetMocks();
  });

 expect(fetchMock.mock.calls[0][0].method).toEqual('GET');

I think this stop failing for me, I don’t remember.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Property 'name' does not exist...
Read more >
APIGateway Default Integration not working - Stack Overflow
I had to create an ANY method on the parent resource ( /foo ). const foo = this.gateway.root.resourceForPath("/foo"); foo.
Read more >
TypeScript Integration with NodeJS | by Ajay Kumar Pandit
You can verify whether typescript is installed or not by typing following command. By running following command you will get typescript version ...
Read more >
TypeScript Programming with Visual Studio Code
No, the TypeScript language service that ships with Visual Studio 2019 and 2022 isn't compatible with VS Code. You will need to install...
Read more >
NextJS x Typescript - Integration & Troubleshooting - Szhshp
NextJS x Typescript - Integration & Troubleshooting. 2020-07-19. Deployments. API not work on Git Pages. Styles. NextJS Custom Font. Include the font.
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