Jest may come across test suites, but it discreetly disregards the individual tests

Having encountered an issue with Jest testing in a Nuxt/Vue v2 project, I found that after making some changes, the tests were no longer running. The unit tests were either passing or failing initially, but suddenly stopped running altogether.

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------
Test Suites: 0 of 10 total
Tests:       0 total
Snapshots:   0 total
Time:        3.454 s, estimated 10 s
Ran all test suites.

Despite trying to bring back the previous code and stashing the changes before rerunning the tests, none of the test suites would execute. Even creating an empty test suite did not trigger any errors such as 'your test suite must contain at least one test', across both the tests/unit directory and other folders.

I usually maintain careful commit practices, but it's possible that I made a mistake along the way. Perhaps there was an issue with the dependency tree, like missing a crucial dependency in package.json (I even reinstalled node_modules from scratch at one point). It could also be a potential dependency mismatch that was previously unnoticed...

What might be causing this problem? How can I troubleshoot this situation effectively given my prior experience with Mocha/Chai?

Below are my configuration settings:

jest.config.js

module.exports = {
  moduleNameMapper: {
    "^@/(.*)$": "<rootDir>/$1",
    "^~/(.*)$": "<rootDir>/$1",
    "^vue$": "vue/dist/vue.common.js",
  },
  moduleFileExtensions: ["ts", "js", "vue", "json"],
  transform: {
    "^.+\\.ts$": "ts-jest",
    "^.+\\.js$": "babel-jest",
    ".*\\.(vue)$": "vue-jest",
  },
  collectCoverage: true,
  collectCoverageFrom: [
    "<rootDir>/some-dir/**/*.(js|ts)",
  ],
  testEnvironment: "jsdom",
  testMatch: ["**/*.spec.(js|jsx|ts|tsx)", "**/*.test.(js|jsx|ts|tsx)"],
  runner: "groups",
};

package.json

  "scripts": {
    …
    "test:unit": "jest"
  },
  "dependencies": {
    …
    "core-js": "^2.6.12",
    "nuxt": "^2.15.8",
    "path-to-regexp": "^6.2.1",
    "vue": "^2.6.14",
    "vue-server-renderer": "^2.6.14",
    "vue-template-compiler": "^2.6.14",
    "webpack": "^4.46.0"
  },
  "devDependencies": {
    …
    "@nuxt/types": "^2.15.8",
    "@nuxt/typescript-build": "^2.1.0",
    "@nuxtjs/device": "^2.1.0",
    "@vue/test-utils": "^1.3.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^27.4.4",
    "jest": "^27.4.4",
    "jest-runner-groups": "^2.2.0",
    "ts-jest": "^27.1.1",
    "vue-jest": "^3.0.4"
  }
}

Answer №1

After upgrading to version 3 of core-js, everything seems to be working fine now. It appears that I accidentally installed version 2 before (which used to be the default for nuxt), then updated to version 3 without using the --save flag, causing issues with versioning.

I decided to keep this question here just in case it can benefit someone else facing a similar issue.

Answer №2

Encountered a similar issue but was able to fix it by updating @testing-library/react to version 14.0.0

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exporting Arrays in Ionic Angular with Typescript is an essential feature

When trying to access an exported component in Typescript, there may be issues with importing the module correctly into another component. An error message is displayed when calling the AddToArray method: Cannot read property 'push' of undefi ...

Is it possible to extract data from a JavaScript Array using scraping techniques?

I have a sample page that I want to extract data from... [ [4056, 1, 'Saturday, Aug 18 2012', '15:00', 171], [4057, 1, 'Saturday, Aug 18 2012', '15:00', 94], [4058, 1, 'Saturday, Aug 18 2012', '15:00& ...

Removing leading zero from ng-change value in controller

One example of my input field is shown below: <input id="0900" type="radio" ng-model="formData.appointment_hour" ng-change="change(0900)" name="appointment" value="0900" class="ng-valid ng-dirty"> After inspecting the function in my controller, I n ...

Dynamically insert textboxes into a form by leveraging the power of the Jade template engine

Looking for a solution to a simple requirement that doesn't seem to have a clear answer online. I need a combobox on my jade page that accepts numbers as input. When the user selects a number, I want the page to refresh and display that many textboxes ...

Converting an MVC form into JSON using Jquery

I am encountering an issue with serializing my MVC form to JSON using JQuery and then deserializing some values, like the input field value, on the backend in C#. I have tried to serialize it in JSON without success. Can someone please assist me with this ...

The getInitialProps function in Next.js React components does not automatically bind props

When building applications with Next.js, you have the opportunity to leverage a server-side rendering lifecycle method within your React components upon initial loading. I recently attempted to implement this feature following instructions from ZEIT' ...

What strategies can be used to manage Error return types in Typescript?

I have a situation where I need to handle either an object of type Person or an Error being returned by a function. My goal is to read the values of keys in the returned object only if it's not an Error. The code snippet below throws an error on the ...

Draggable bar charts in Highcharts allow users to interact with the data by clicking

I'm working on creating a chart that allows for setting values by clicking and dragging. While the dragging functionality is working fine, I've run into an issue with the click event. When I click to set a new value, the draggable feature acts er ...

Leveraging the power of ReactJS and TypeScript within a Visual Studio environment for an MVC5 project

I am currently working on creating a basic example using ReactJS and TypeScript in Visual Studio 2015. Despite following several tutorials, none of them have met my specific requirements or worked as expected. My goal is to develop components as .tsx fil ...

Overlay a small image on top of a larger background image using canvas, then merge them into a single set of pixel

Is there a way to combine a smaller image with a larger background image on one canvas while allowing the smaller image to move around? I'll need to save the original background pixel data so that each frame can be redrawn with the overlay in its upda ...

Struggling to solve a never-ending loop problem in a messaging application

I am currently in the process of developing a chat application. During the initialization of the chat page, I am checking for messages and storing them in an array. ngOnInit() { this.messageService.getMessages().doc(`${this.sortItineraries[0] + ...

Issue encountered when attempting to connect an external script to a Vue single file component

Struggling to link an external script to a single file component in Vue. My project setup is as follows: I need to link the file components/Sshy to ../javascripts/ I have successfully linked other scripts using either of these methods before: ../javasc ...

Modify the JSON structure of a deeply nested object

I am attempting to convert a deeply nested JSON object from one structure to another so that it can be properly used with the jQuery Nestable library. Here is the original format I am working with: { "scanned": { "a3": { ...

VSCode highlights issues that do not impact the compilation process

While working in VSCode, I notice numerous issues with TypeScript syntax, but oddly enough, these problems do not impact the compilation process. It's puzzling to me why my colleagues are unable to see these issues like I do. Is there a way for me to ...

Ways to verify if Arabic text has been submitted by the user through a form?

Is there a foolproof method for detecting Arabic input in a form before submission? Can Javascript effectively manage this task, or is it better handled by server-side scripts like .NET? I propose implementing a script to immediately block users from ente ...

Providing Express with static files

I have created a Node.js application using express. When I make a request to /, I want to serve the file located at /public/app/index.html. This part is working fine. However, within the index.html file, there are references to two CSS and two JS files wit ...

Adding items to an array retrieved from JSON

My goal is to merge 3 different Facebook feeds into a single object called "item." Each item includes the post creation time and the JSON data itself. However, I'm facing an issue where only 5 items are displayed when I check the log, even though ther ...

JQuery/JS function not functioning as expected

Creating HTML with jQuery to retrieve data from a web API. At the start of my script, I defined a function that checks the selected value of a dropdown and assigns it to a global variable. var $seldom; $(document).ready(function () { function chkdom() ...

Issues with jwplayer functionality

After downloading the necessary files and carefully following all instructions, I am still experiencing issues with the player not functioning as expected. <code> <html> <head> <script type="text/javascript" src="/jwpl ...

In search of an effortless method to effortlessly select numerous elements using a handy bookmarklet

My goal is to develop a bookmarklet that can perform various functions on different webpages with ease. The concept involves placing it in a convenient location, such as the bookmark bar, and executing a "standard function" on a particular page. Instead of ...