Questions tagged [ts-jest]

451 questions
7
votes
1 answer

Configure jest timeout once for all tests

According to the docs one can increase the default async timeout from 5000ms using the jest-object More specifically, by using the jestsettimeouttimeout The issue I am facing is I am running a series of tests against an API that is very slow, 5-15…
John
  • 4,512
  • 8
  • 48
  • 98
7
votes
3 answers

How to use jest.spyOn with React function component using Typescript

I am developing a React app using Typescript, and hooks, and I am trying to use Enzyme with Jest to test the function components. I am unable to use jest.spyOn to test a method in my component. The jest.spyOn method doesn't resolve correctly and…
codermav
  • 185
  • 1
  • 8
6
votes
1 answer

Typeorm decorator is not a function

I have the following controller that I want to test : class Album { public static getAlbums(): Promise { return getRepository(AlbumModel).find({ relations: ['pictures'] }); } } Which is linked to a model, i'm using typeorm…
TLd
  • 165
  • 14
6
votes
1 answer

How to let TypeScript know about custom Jest matchers?

I have a react/typescript project, using jest, where I have a custom matcher like: export const MyCustomMatchers = { toBeTheSameAsRemote: function(_util: any, _customEqualityTesters: any) { return { compare: function(actual:…
johncol
  • 444
  • 6
  • 11
6
votes
3 answers

React Jest test fails to run with ts-jest - Unexpected token on imported file

I have a test for a test for a TSX file written in a JSX file which fails to run due to unexpected token: Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest…
Antfish
  • 849
  • 15
  • 34
5
votes
1 answer

"SyntaxError: Cannot use import statement outside a module" when writing test with typescript with lit-html

I use typescript to write a simple demo with lit-html: import {html, TemplateResult} from 'lit-html'; export default function sayHello(name: string): TemplateResult { return html`

Hello ${name}

`; } and use jest to write some simple…
Freewind
  • 177,284
  • 143
  • 381
  • 649
5
votes
2 answers

Vuetify Jest Unknown custom element

I am writing unit tests for my project, using Jest. Project is based on Vue, Vuetify (1.5) and TypeScript (and vue-property-decorator). I have basic wrapper for . It looks like this: