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

166
Views
Jest Coverage 100% even tests are failed

Jest Version 24.9.0

Steps to reproduce

  1. I am using vue@2.6.14, @vue/cli-service@4.5.18 , jest@24.9.0, @vue/cli-plugin-unit-jest@4.5.18 , typescript@3.9.10
  2. Previously I was using node 14 and esnext. Jest Coverage was working fine, there was no issues
  3. Later I updated node 14 to 16 and esnext to es2019 and configured snapshots as well, then lost my coverage. Then reverted my changes, still facing coverage issue.

Even if any tests failed, its giving 100% coverage

Jest Configuration :

collectCoverageFrom: ["src/**/*.vue"]

"test:unit": "npm run requirements-check && vue-cli-service test:unit --colors --coverage --maxWorkers=4 -u"

Node: 14.15.4 npm: 6.14.10

Sample testcase (its enough to get 100% coverage even file has multiple functions) :

describe("Can able to see page is mounted", () => {
  let i18n: VueI18n;
  let localVue: VueConstructor<Vue>;
  let routerMock: any;
  let wrapper: Wrapper<test& {
    [key: string]: any;
   }>;

beforeEach(() => {
    localVue = createLocalVue();
    localVue.use(plugins);
    localVue.use(VueI18n);
    localVue.prototype.$notify = jest.fn();
    localVue.config.ignoredElements = [/vl*/];

    window.scrollTo = jest.fn();

    routerMock = {
        $router: {
        replace: jest.fn(),
        push: jest.fn(),
        go: jest.fn()
      }
    };

    wrapper = mount(test, {
      i18n,
      localVue,
      mocks: routerMock,
      directives: {
        "full-screen-loading": jest.fn()
      },
      stubs: ["router-link", "router-view"]
    });
  });

  it("test", () => {
     expect(wrapper.exists()).toBe(true);
     expect(wrapper.find(".test").exists()).toBe(true);
     expect(wrapper.element).toMatchSnapshot();
  });
});
about 4 years ago · Santiago Trujillo
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!