-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
Please try out Jest 24 if you're having issues with missing console.log
output
Branching from Issue #2441
@cpojer I'm not seeing any console.log output with this setup (macOS):
$ node --version
v7.4.0
Files
package.json
:
{
"dependencies": {
"@types/jest": "19.2.4",
"jest": "20.0.4",
"ts-jest": "20.0.6",
"typescript": "2.3.4"
}
}
__tests__/jestconfig.json
:
{
"rootDir": "../",
"globals": {
"__TS_CONFIG__": {}
},
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json"
],
"transform": {
"\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "__tests__/.*test_.*\\.(ts|tsx|js)$"
__tests__/test_foo.ts
:
import {} from 'jest';
console.log('CONSOLE before test');
test('fail', () => {
console.log('CONSOLE inside test');
expect(true).toEqual(false);
console.log('CONSOLE end of test');
})
__tests__/test_bar.js
:
console.log('BAR CONSOLE before test');
test('fail', () => {
console.log('BAR CONSOLE inside test');
expect(true).toEqual(false);
console.log('BAR CONSOLE end of test');
})
Output
$ jest -c __tests__/jestconfig.json
FAIL __tests__/test_foo.ts
● fail
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous> (__tests__/test_foo.ts:6:16)
at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
FAIL __tests__/test_bar.js
● fail
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous>.test (__tests__/test_bar.js:4:16)
at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
Test Suites: 2 failed, 2 total
Tests: 2 failed, 2 total
Snapshots: 0 total
Time: 1.379s
Ran all test suites.
Single JS test:
$ jest -c __tests__/jestconfig.json __tests__/test_bar.js
FAIL __tests__/test_bar.js
● fail
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous>.test (__tests__/test_bar.js:4:16)
at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
✕ fail (7ms)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 0.596s, estimated 1s
Ran all test suites matching "__tests__/test_bar.js".
Single TS test:
$ jest -c __tests__/jestconfig.json __tests__/test_foo.ts
FAIL __tests__/test_foo.ts
● fail
expect(received).toEqual(expected)
Expected value to equal:
false
Received:
true
at Object.<anonymous> (__tests__/test_foo.ts:6:16)
at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
✕ fail (116ms)
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 1.27s
Ran all test suites matching "__tests__/test_foo.ts".
eranimo, marvinhagemeister, AJamesPhillips, cooperka, sorenlouv and 22 more