'How can I print test case messages with its run time in Jest?
I am using Jest (version ^27.4.7). I want to print test case message with its execution time. How can I do that? I am using NodeJS/TypeScript.
Is this called console.log in Jest?
some.spec.ts
describe('healthCheck', () => {
it('successful response', async () => {
});
it('error handling', async () => {
});
});
Current Result:
Expected Result (I want to show messages for each spec):
healthCheck
successful response (xx ms)
error handling (xx ms)
Jest Configuration in package.json:
{
"transform": {
"^.+\\.ts?$": "ts-jest"
},
"testEnvironment": "node",
"testMatch": [
"**/?(*.)+(spec|test).ts"
],
"testPathIgnorePatterns": [
"/lib/",
"/node_modules/"
],
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
],
"collectCoverage": true,
"collectCoverageFrom": [
"**/*.ts",
"!**/*container.(t|j)s",
"!**/*app.(t|j)s",
"!**/*mockData.(t|j)s",
"!**/*routes.(t|j)s",
"!**/*server.(t|j)s",
"!**/*asyncWrap.(t|j)s",
"!**/*errorHandler.(t|j)s"
],
"roots": [
"<rootDir>/src"
],
"coverageThreshold": {
"global": {
"branches": 80,
"functions": 80,
"lines": 80,
"statements": 80
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|


