jestjs Questions
3
Solved
I am migrating an Angular workspace with Karma to an Nx workspace with Jest. I'm having a couple of issues, one of them being the use fakeAsync, which results in the following error:
Expected to be...
3
I've successfully tested one isolated server component by using an async it and awaiting the output of a call to the component as a plain function to pass into render:
it('renders the user data wh...
Chambertin asked 10/2 at 1:15
3
I'm a newbie on test driven development, and I came across a section regarding testing/mocking a fetch api. But I'm struggling to write my own test. I built a simple weather app just to test/mock t...
Pressing asked 4/9, 2022 at 5:45
4
I am building a chat app and would like to write integration tests using react-testing-library and can not figure out how to mock socket.io-client's socket.on, socket.emit, etc.
I tried follow thi...
Bradwell asked 3/10, 2019 at 2:44
2
Solved
I'm trying to unit test a function that returns a promise. I'm having challenges verifying if
the mocked functions are called. Here's what I've done.,
// codetotest.js
const { SomeModule, isSomethi...
Flam asked 14/5, 2021 at 17:15
9
Solved
I have an API class that I am trying to use in a React app.
// API file
class API {
...
}
export default API;
// Other file
import API from "utils/API";
const api = new API();
And I ...
Excommunicative asked 15/4, 2022 at 22:53
3
I have a resuable component, called DatePicker like this
export interface IPDatePicker extends IProps {
control: any
label: string
placeholder: string
value?: string
errorText?: string
isRequ...
Wattage asked 6/4, 2022 at 4:51
2
Solved
Im trying to create a basic jest test interacting with a npm dependency: react-diagrams
The failing test
import { DiagramModel } from '@projectstorm/react-diagrams'
test('importing react diagrams'...
3
Here's my jest config inside of package.json:
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"moduleDirectories":["...
Privet asked 25/6, 2021 at 8:44
2
When I run Jest in a terminal with a light background, its yellow output is totally unreadable.
I have tried to find any options that allow me to customize the colors, or turn off output coloring ...
Klingensmith asked 23/5, 2019 at 1:19
3
I'm working on a Nuxt.js project and using Vitest for unit testing. I need to verify if the navigateTo function from Nuxt.js is called with a specific path in my tests.
Here's the relevant part of ...
3
This is my first time working with jest. I have a scenario where I want to see if the selected value is in an enum or not. Here is my test case:
test('Should be valid', () => {
expect(TestCase...
Perbunan asked 13/9, 2022 at 4:9
5
Solved
I have a very simple Node.js (12.16.3) application that uses Express 4.17.1. I'm trying to use Jest 26.0.1 to run the test suite, but the same is failing due to some issue with the uuid module (ver...
5
Solved
I'm using now.sh to deploy my nextjs (React) app. And the build is failing due to this error:
Build error occurred
ReferenceError: describe is not defined
Not sure why this started happening, her...
Homburg asked 8/9, 2019 at 3:7
2
Solved
Class to test
My TypeORM repository extends AbstractRepository:
@EntityRepository(User)
export class UsersRepository extends AbstractRepository<User> {
async findByEmail(email: string): Pro...
Wellworn asked 29/12, 2021 at 15:9
5
I am trying to successfully run the boiler place App-test.js test that comes with the react-native installation. I have seen this test work "out of the box" with other projects, however, mine fails...
Selfgratification asked 5/4, 2020 at 13:0
5
I have React function component that has a ref on one of its children. The ref is created via useRef.
I want to test the component with the shallow renderer. I have to somehow mock the ref to tes...
Melchior asked 5/9, 2019 at 12:51
3
Is it possible to maintain the same render() across multiple tests in using Jest and React Testing Library? I am building a Trivia App and have a single component that displays different questions ...
Barth asked 9/7, 2020 at 19:46
3
While I've tried to test my form component that uses useFormState and Next14 Server Actions I get this error TypeError: (0 , _reactdom.useFormState) is not a function or its return value is not ite...
0
I've been trying to resolve this test error for a while now with not success. Recently I upgraded React Native from 0.72.3 to 0.74.3 and got the Android application to build and run, however, I can...
Homicide asked 29/7 at 10:9
4
--- UPDATE----
I can run the test using command line but can't run the test with Jest Runner extension in VSCode.
------Original Question -----------------
I think I have corrupted my npm modules b...
3
I have been using jest for unit testing in my react project (typescript). Now I have enabled path alias in webpack and tsconfig. In order to use path alias with jest, I have followed this tutorial....
Maryn asked 28/6, 2018 at 10:47
3
Solved
I'm setting up the tests for my web application, which works with the Vue framework with TypeScript, using the Jest framework. Everything seems to work alright, except with the @ symbol in my impor...
Helvellyn asked 2/7, 2020 at 8:18
2
Solved
I am newbie at React and I can not find a solution for a simple problem.
I am using create-react-app and I succeed to operate jest snapshot test. Then, for trying I changed render() function's ins...
Gradual asked 25/7, 2018 at 20:42
3
I have been trying for several hours to test an endpoint of my rest api with Jest, Supertest and Express.
This endpoint is protected by an authentication middleware named "advancedAuthGuard&qu...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.