ts-jest

When mocking a class in typescript using jest/ts-jest I am getting “TypeError: ”X“.default is not a constructor.”

∥☆過路亽.° 提交于 2019-12-25 03:15:37
问题 I am writing a unit test using jest/ts-jest in typescript and I am trying to mock a class but I am getting a TypeError. "storage_1.default is not a constructor". Here is how I am mocking the class. index.test.ts import GetAdaptiveCard from '../../GetAdaptiveCard/index' const mockGetAdaptiveCard = jest.fn(); jest.mock('../../utils/storage', () => { return jest.fn().mockImplementation(() => { return { getAdaptiveCard: mockGetAdaptiveCard } }) }) test('http trigger should return adaptive card',

I cannot configure jest properly to import modules (setupFilesAfterEnv)

◇◆丶佛笑我妖孽 提交于 2019-12-24 10:03:46
问题 I am using @angular-builders/jest in order to replace karma by jest when testing angular projects. There are 2 libraries that I like to get extra matchers for jest: jest-extended and @testing-library/jest-dom . I cannot find a way to import automatically the matchers so that I don't have to import them in each spec file. minimal example to reproduce the problem with jest-extended First, create an angular project and install jest dependencies ng new --defaults my-project cd my-project yarn add

cannot find name it in jest typescript

此生再无相见时 提交于 2019-12-08 01:35:50
问题 I try to create an intial setup for jest in react + typescript.I have completed the initial setup and try to check whether the test runs. When i run the test using the command npm test i am getting the following error Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`. I have installed the types for jest as well as removed the types in tsconfig.json but still i am getting the same error. { "compilerOptions": {

cannot find name it in jest typescript

你离开我真会死。 提交于 2019-12-06 06:07:45
I try to create an intial setup for jest in react + typescript.I have completed the initial setup and try to check whether the test runs. When i run the test using the command npm test i am getting the following error Cannot find name 'it'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`. I have installed the types for jest as well as removed the types in tsconfig.json but still i am getting the same error. { "compilerOptions": { "target": "es6", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true,