Jest- not getting coverage for Object.key line
I have a function that takes in an object, manipulates it, checks that the manipulated object still contains data, then iterates through the object’s keys using Object.keys
/ forEach
and passes the data to another function. This all works, but Jest is saying I don’t have coverage for the Object.keys
lines, despite several tests that test this function successfully:
Jest don`t respect BEFOREALL
let maybe = test.skip; //code to SKIP TEST beforeAll(async () => { maybe = test //CODE TO DONt SKIP TEST }); describe(‘this a describe’, () => { maybe(‘XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’, async () => { expect(true).toBe(true) }); }) Whenever I run this test, it shows as test.skip, but I have set up beforeAll, so it should execute as […]
How to use Jest to test server and DB setup in following code?
const express = require(“express”); const mongoose = require(“mongoose”); const bodyParser = require(“body-parser”); const cors = require(“cors”); const dotenv = require(“dotenv”); const app = express(); dotenv.config(); const PORT = process.env.PORT || 8070; app.use(cors()); app.use(bodyParser.json()); const URL = process.env.MONGODB_URL; mongoose.connect(URL, { useNewUrlParser: true, useUnifiedTopology: true }); const connection = mongoose.connection; const labRouter = require(‘./routes/lab.js’); app.use(“/lab”, labRouter); connection.once(“open”, […]
How to Call a Function Needed for a File listed under setupFiles in Jest?
I’m using setupFiles
in Jest to call an authentication flow for a new test framework. As part of that effort I’ve started abstracting common request types to a separate file, then referencing them in my auth setup file.