Questions tagged [jest-fetch-mock]
99 questions
0
votes
1 answer
Testing fetch action in react/redux app
Im starting with unit testing and Jest. What I want is to test the action's response after fetching some resources from the db.
This is the action code:
export function loadPortlets() {
return function(dispatch) {
return…

diegoalmesp
- 162
- 1
- 13
0
votes
1 answer
jest mock setup with fetch-mock
I am not sure why but the test fails as it says Expected mock function to have been called.. How should I setup the addFundingSource mock to have it called? I can't jest.mock the whole module like the others (for instance…

Sean Magyar
- 2,360
- 1
- 25
- 57
0
votes
1 answer
Jest test cases are not failing as well not passing
My Package.json code:
"dependencies": {
"gulp-jest": "^2.0.0",
"jest-cli": "^20.0.4",
"supertest": "^1.2.0"
}
"scripts": {
"test": "gulp test"
}
my gulpfile test tasks are as
gulp.task('run-tests', (done) => {
…

Nikita S
- 139
- 2
- 11
0
votes
1 answer
What is Expect function to validate schema in JEST and Supertest?
like in chakram testing expect(WallObject).to.have.schema(expectedSchema). Similarly which function is there in Jest? I am using jest with supertest.

Nikita S
- 139
- 2
- 11
-1
votes
1 answer
Unable to mock utility function using import.meta to read file in Jest test
I am reading a a file using import.meta to resolve the directory which fails when trying to mock it in a function. Here is the part of the code which I want to mock
// readFileUtil
const __filename =…

BreenDeen
- 623
- 1
- 13
- 42
-1
votes
1 answer
Jest testing conditional response
I have data
const data = {
animal: 'cat',
isBlack: true
}
What I wish my component to render some text if the cat is black and not to render if the cat is not black. I have several tests
describe('About', () => {
const data = {
animal:…

Katharina Schreiber
- 1,187
- 2
- 11
- 38
-1
votes
1 answer
How to write a test case for this function in jest
// Code for Timer Function//
Function startTimer (event)
{
var session Timeout=
setTimeout (function ()
{
Self.postMessage (
{
Message:'show dialog'
};
);
}, event.duration);
}
How to write test…

Tamanna Thakur
- 29
- 2
-1
votes
1 answer
Jest Mock not returning the mock data while writing Unit Test in react
I am calling an API using fetch and writing test cases for that. While making the Fetch call, I am expected mocked data but getting API error message.
Please help me to know why its not mocking the data.
Using Jest, jest-fetch-mock modules. Code is…

Anand Deep Singh
- 2,560
- 3
- 22
- 28
-2
votes
1 answer
Can anyone help how I should start or give me an abstract form of the possible unit tests I can write
import service from "Api/service";
import { ROOT_URL, saveError } from "Api";
import {
FETCH_USER_REQUEST,
FETCH_USER_FAILURE,
FETCH_USER_SUCCESS
} from "Constants/redux";
// it fetch the details of an user
export const fetchDetails = () => {
…

Akshay Garg
- 3
- 1