Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

158
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda