Testing complete. Exiting with code 1 as no tests were discovered

When I run the jest command, this is the output I receive:

$ jest
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In /Users/igormakowski/Documents/repositories/nestjs-template
  9 files checked.
  testMatch:  - 0 matches
  testPathIgnorePatterns: /Users/igormakowski/Documents/repositories/nestjs-template/node_modules/, /Users/igormakowski/Documents/repositories/nestjs-template/dist/, /Users/igormakowski/Documents/repositories/nestjs-template/.stryker-tmp/, .js - 0 matches
  testRegex: .*\.spec\.ts$ - 1 match
Pattern:  - 0 matches
error Command failed with exit code 1.

Although 1 test is found, Jest does not execute it for some reason. This configuration is very similar to another project where everything works fine.

jest.config.ts

import type { Config } from 'jest'

const configuration: Config = {
  moduleFileExtensions: ['js', 'json', 'ts'],
  rootDir: '.',
  testRegex: '.*\\.spec\\.ts$',
  // testMatch: ['<rootDir>/src/**/*.spec.ts'],
  transform: {
    '^.+\\.(t|j)s$': 'ts-jest',
  },
  verbose: true,
  collectCoverageFrom: ['**/*.(t|j)s'],
  testPathIgnorePatterns: [
    '<rootDir>/node_modules/',
    '<rootDir>/dist/',
    '<rootDir>/.stryker-tmp/',
    '.js',
  ],
  moduleNameMapper: {
    '^~/(.*)$': '<rootDir>/src/$1',
    '^@modules/app(.*)$': '<rootDir>/src/modules/$1',
    '^@common/filters(.*)$': '<rootDir>/src/common/$1',
  },
  coveragePathIgnorePatterns: [
    '.*\\.(interface|module|schema|entity|dto|enum|d).ts',
    '.*\\.e2e-spec.ts',
    'index.ts',
    'main.ts',
  ],
  coverageDirectory: './coverage',
  testEnvironment: 'node',
  roots: ['<rootDir>/src'],
}

export default configuration

My system details:

System:
    OS: macOS 13.2.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 18.14.2 - ~/.nvm/versions/node/v18.14.2/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.14.2/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.14.2/bin/npm
  npmPackages:
    jest: 29.5.0 => 29.5.0

To reproduce the issue: https://github.com/Mnigos/nestjs-template

I have tried newer versions of Jest (29.6.1), using testMatch instead of testRegex, reinstalling dependencies, reloading the VSCode project, and various Jest flags like:

jest --testMatch **/src/**/*.spec.ts
jest --config jest.config.ts
./node_modules/.bin/jest --config jest.config.ts

Answer №1

To execute jest using a custom configuration file, make sure to utilize the --config option.

jest --config jest.config.ts

For additional information, visit this link.

Update: Don't forget to exclude '.js' from testPathIgnorePatterns.

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

Unable to assign Angular 2 service data to a variable within the constructor

I am facing an issue in my Angular 2 application where I need to assign the data returned from a service function to a public variable and display it in the HTML view. While the console log shows that the data is successfully fetched, it does not seem to b ...

Angular2 Error: TemplateRef provider missing in ng2-bootstrap

I've been attempting various solutions to address this issue, but unfortunately haven't been successful in resolving it: No provider for TemplateRef! Error log: EXCEPTION: Uncaught (in promise): Error: Error in ./FooterComponent class FooterC ...

Error message: Orbit controls have encountered an issue - Uncaught TypeError: Cannot access property 'ROTATE' when it is undefined

Yesterday, the code was functioning properly until it suddenly started displaying an error in the orbit control JS file on line 82. The error message reads as follows: Uncaught TypeError: Cannot read property 'ROTATE' of undefined at new THREE.O ...

Customize cursor using CSS

I have a div with overflow: hidden that I am making scrollable by allowing the user to click and drag the background. There are links and buttons within this space. Here is the CSS I am using for this: #div-grabscroll { cursor: url(../img/op ...

Tips for efficiently storing and managing large data volumes in real-time applications

I am currently developing a real-time collaborative canvas project. Users have the ability to create rooms and invite others to join with a specific ID and password. The application also supports multiple tabs and utilizes fabric.js for handling canvas ope ...

Instructions on activating dark mode with the darkreader plugin on a Vue.js website

Is there a way to implement DarkMode in a Vue.js application? I attempted to integrate darkmode using this npm package, but I kept encountering the error message: DarkMode not defined. ...

Unable to exclude specific files using VSCode's "files.exclude" feature

In my workspace settings file, the configuration for excluding certain files is as follows: { "files.exclude": { "**/*.js": { "when": "$(basename).ts" }, "app/**/*.js.map": { "when": "$(basename).ts" ...

Transforming Jquery into vanilla JavaScript and sending a POST request

Hey everyone, I'm in the process of converting Jquery code to pure javascript and encountering some difficulties with the following snippet: $.post('ajax_data',{action:'service_price',service:service,quantity:quantity,dripfeed:drip ...

Troubleshooting the Ui-router refresh problem

I set up my ui-router configuration as follows: app.config(function($stateProvider, $urlRouterProvider, $locationProvider) { $stateProvider .state('home', { url: "/home", templateUrl : 'h ...

What causes the imported constant in Vue to fluctuate in value?

In my Vue component, I am importing an array named CHART_CARDS. This array is used to set the initial state for another array called chartCards, which can be modified by the user. import { CHART_CARDS } from '~/constants/chartCards' ... export ...

Tips for showcasing events posted in a GET endpoint

I need to display the events received in a post route within my get route. Here is the route that handles incoming requests: app.post('/events', (request, response) => { console.log(request.body); response.send(request.body); Everything is f ...

A Node.js function may not provide a response immediately due to a pending request

Here is a simple upload method using node.js and express.js: upload: function(req, res, next){ // Loop through each uploaded file async.each(req.files.upload, function(file, cb) { async.auto({ // Create new path and unique file ...

Adding data to a JSON object using AngularJS

When attempting to insert an object into a JSON object, I am encountering an issue where it duplicates the JSON object. Here is a breakdown of the scenario: <input type="text" style="width: 40% !important;" placeholder="Nom" class="input-sm" ng-model= ...

Angularfire2 retrieve list of data with a specified number of items from the

I am facing a challenge in retrieving a specific node from my firebase database. https://i.sstatic.net/YDevB.png The technologies I am using include: "angularfire2": "^5.0.0-rc.4", "firebase": "^4.9.0", In my component code, you can find the following ...

The Puppeteer script ran into a timeout error of 3000 milliseconds while attempting to click a button used to filter search

Here is the code snippet I am working with: const puppeteer = require("puppeteer"); (async () => { try { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto("https://www.genglobal.org/member-d ...

Encountering a tIDENTIFIER syntax error while trying to include a button_tag in Rails

Currently, I am in the process of developing a rails application and my aim is to incorporate a button that executes a javascript onclick function. The code snippet I am using for this purpose is: <%= button_tag "Action" type: "button", onclick: "test( ...

Exploring nested JSON data: Tips on accessing values

I am currently working with nested JSON data and I am still learning the ins and outs of JavaScript and JSON logic. Despite my efforts to research and understand, I am struggling to make my app function as desired. Below is an image representing the data: ...

Execute a JavaScript function with PHP if statement

I need to use PHP variables to trigger a JavaScript function based on an if statement. If the condition is true, the script will execute using another PHP variable. <?php if ($time_close_option == 1){ echo '<script type="text/javascrip ...

Vue 2.0: Exploring the Power of Directive Parameter Attributes

It has come to my attention that directive param attributes have been phased out in Vue.js 2.0. As a result, I am unable to use syntax like v-model="msg" number within an input tag. Are there alternative methods to achieve the same outcomes without relyi ...

show the day of the week for a specific date saved in a MongoDB database

I need to create a report showing the total number of purchases for each day in the past week, formatted like this: { "sunday":30, "monday":20, ... } Each purchase in the database is structured as follows: { _id: 603fcb ...