Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
Jest config for supertest and Vue

I have an application that uses vue and express and I have tests written for each, I can run either a vue test on it's own or the express test on it's own.

Below is the jest config file this will run fine for Vue, if I remove the preset it will work fine for my supertest/express test .

module.exports = {
// TODO: This line is needed for vue tests but breaks js tests
preset: "@vue/cli-plugin-unit-jest",


coverageDirectory: "test-reports/",
    coveragePathIgnorePatterns: [
      "/node_modules/"
    ],
  reporters: [
    "default",
    [
      "jest-junit",
      {
        outputName: "vue_junit.xml",
        outputDirectory: "test-reports/",
      },
    ],

  ],
};

For reference here is both the tests if it helps

// Libraries
import Vuetify from "vuetify";
import Vue from "vue";

// Components
import UserBar from "@/components/userBar.vue"

// Utilities
import { createLocalVue, shallowMount } from "@vue/test-utils";

// Setup Up
const localVue = createLocalVue();
const vuetify = new Vuetify();
Vue.use(Vuetify);

describe("userBar.vue", () => {
  let wrapper;

  beforeEach(() => {
    wrapper = shallowMount(UserBar, {
      localVue,
      vuetify,
    });
  });
  afterEach(() => {
    wrapper.destroy();
  });

  it("wrapper created properly", () => {
    expect(typeof wrapper).toBe("object");
  });
});

express test

var request = require('supertest');
import * as local from '../../server';

var express = require('express');
var app = express();
describe('loading express', function () {
  var server;
  beforeEach(function () {
  delete require.cache[require.resolve('../../server/index')];
  server = local.default(app);
});
  afterEach(function (done) {
    server.close(done);
  });
  it('responds to /client', function testSlashHealth(done) {
  request(server)
    .get('/client')
    .expect(200, done);
  });
  it('404 everything else', function testPath(done) {
    request(server)
      .get('/foo/bar')
      .expect(404, done);
  });
});
about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Got around this by specifying 2 config files when testing

jest -c jest.config.express.js

jest -c jest.config.vue.js

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!