Questions tagged [jestjs]

Jest is a JavaScript unit testing framework made by Facebook based on Jasmine and provides automated mock creation and a jsdom environment. It's often used for testing React components.

Filter by
Sorted by
Tagged with
0
votes
0answers
13 views

Jest-Native “SyntaxError: Cannot use import statement outside a module”

Trying to do some unit testing using https://github.com/callstack/react-native-testing-library + https://github.com/testing-library/jest-native, I have no problem testing plain javascript files, but I ...
0
votes
0answers
10 views

Mocking react custom hook

I need to mock useLogin hook, bacause it contains logic that throws an error. Later i will test it in isolationю. UseLogin returns loading flag and login function that connecting new user to firebase. ...
0
votes
0answers
6 views

next-i18next Jest Testing with useTranslation

Testing libs...always fun. I am using next-i18next within my NextJS project. We are using the useTranslation hook with namespaces. When I run my test there is a warning: console.warn react-i18next::...
0
votes
1answer
18 views

React component not setting state after mocking redux

Here is my test const initialRootState = { accounts: [mockAccounts], isLoading: false } describe('Account Dashboard', () => { let rootState = { ...initialRootState } const mockStore ...
0
votes
1answer
12 views

How can I write a unit test using jest, react, testing-library for this component?

I need to write unit tests using Jest and testing-library in a React typescript project. And how can I create an ID for my component ErrorModal to use in my test? I never wrote a test before!! Thank ...
0
votes
0answers
11 views

getElementById returns 0 in (jest) testing, but works fine in browser

I've built my first app with create-react-app , and I'm trying to include a simple test. Somehow the test always returns TypeError: Cannot read property 'classList' of null even though the code works ...
-1
votes
0answers
5 views

calling component.ngOnInit() throws error in Jest but works in Jasmine

I was writing unit test cases for my Angular application previously using Jasmine. Calling component.ngOnInit() in my test suite used to call the ngOnInit() method. But when I do the same in Jest, it ...
0
votes
0answers
11 views

How do I hook into Jest to write a Logging Plugin?

I'm looking to create a logging plugin for Jest. I'm hoping to create a log with all of the major events, catch and rethrow the errors, and make a nice log file of everything happening in a Jest test ...
0
votes
0answers
4 views

Jest test fails to run with ts-jest after deleting babelrc- Unexpected token on imported file

Similar issue: Jest fails to run .tsx files (CRA 2, enzyme) I am converting js test files to ts files, and I use ts-jest. As I know, If I use ts-jest, I don't need babel anymore. But when I delete ....
-1
votes
0answers
13 views

react testing library test failing due to callback

Im trying to mock a callback function on react testing library in a next.js project, but my test fails as the callback is not being called any tips in how to fix this? I have inserted the code for the ...
0
votes
0answers
4 views

FluentUI - suppress “The icon 'X' was used but not registered” warning

I'm writing a react app that uses fluentUI. while working on the system everything is fine (ofc I'm calling initializeIcons() function). however, when I'm running my test using jest, I keep getting ...
0
votes
0answers
4 views

Snapshot fail on version attribute in html update

it('match snapshot on data load',() =>{ Createwrapper(); Expect(wrapper) .toMatchSnapshot(); });
0
votes
1answer
17 views

How to mock a specific Node function with Jest

I have a module with two functions. const exampleFunctionOne = () => { }; const exampleFunctionTwo = () => { }; In my test file I am mocking exampleFunctionOne as so: let mockExampleFunctionOne ...
0
votes
0answers
15 views

How to test a method that closes an MatDialog using Jest

I have a method called downloadFile() which I want to test using Jest. I have a model for Attachment which is shown below: export class Attachment{ name: string; lastUpdateBy: string; ...
1
vote
0answers
37 views

is there a way to mock the the Promise.resolve in a function

So I tried to mock a jwt.verify function. below is the function itself and then the mock. try { const decodedJwt = new Promise((resolve, reject) => { jwt.verify( token, ...

15 30 50 per page
1
2 3 4 5
1011
 
久草视频新免费_日韩视频一中文字暮_欧美三级片