-
Notifications
You must be signed in to change notification settings - Fork 292
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests are failing when running with plugin but working fine with command line #408
Comments
from toubleshooting :
|
Tried jest.pathToConfig: src/test/testSetup.js output:
|
did you try |
you mean "jest.pathToJest" ? |
Jest shows that tests are ok but I changed intentionally one test and reloaded vscode window. Nothing has changed. |
ok, you are making progress...
Basically you need to tell the plugin about your env, which means to setup
meaning every tests shows empty circle? What does the output console show? Also in your post, I saw
is your repo under git? The plugin does run watch mode, if your repo can't be "watched", it won't show status... |
Yes an empty green circle.
Yes it is. Output:
|
I downloaded your repo to my mac, vscode-jest worked flawlessly without any customization as far as I can see. Change the test file also reflected as expected. the error:
I looked at your repo, there is indeed no test in that directory... not sure if this is a windows specific issue, in that case maybe somebody else with a windows env is better suited to help... |
I have even moved testSetup.js to src and now I got just the same output as in my first message. |
@connectdotz I am also getting this issue on macosx high sierra .. I'm running a monorepo though. When I open the workspace at my monorepo root, the test is failing. When I open the individual package root directly in vscode, it passes. |
I have some tests running fine in terminal (both on windows and linux/ubuntu) and vs-code on windows, but failing in vs-code on linux/ubuntu.
|
I simply gave up on vscode-jest. Our tests are very sluggish and this plugin just stresses it out. I'm happy with jest command line ability to launch a separate test instead of all tests at once and the attach ability of vscode debugger. Maybe if I could setup this plugin to run with |
For people with performance issues or having problems getting the extension to start for your environment, please give v4.0.0-alpha.5 a try, it has now an interactive mode that users can control what test to run and when; as well as a "Setup Wizard" to help set up the extension for you. |
Re-opening this issue, I'm experiencing this both on v5 and v6 Environment
Prerequisite
Relevant Debug InformationTSConfig.json{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"lib": [
"DOM",
"DOM.Iterable",
"ES2019"
],
"paths": {
"src": ["./src",],
"src/*": ["./src/*",],
},
"strict": true,
"strictNullChecks": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"isolatedModules": false,
"allowJs": false,
"sourceMap": true,
"noEmit": false,
"jsx": "preserve",
"incremental": true
},
"exclude": [
"node_modules",
"dist",
"esm",
".next",
"out",
"types",
"./README.md",
],
"include": [
"./src",
]
} Source code being tested// date-fns-tz@1.3.8
import getTimezoneOffset from 'date-fns-tz/getTimezoneOffset';
export type LookupValues<T> = T[keyof T];
export const TIMEZONES = {
PST: 'PST',
EST: 'EST',
CST: 'CST',
MST: 'MST',
JST: 'JST',
} as const;
export type SupportedTimezones = LookupValues<typeof TIMEZONES>;
export const TIMEZONE_TO_NON_DAYLIGHT_SAVINGS_DATE: Record<SupportedTimezones, Date> = {
[TIMEZONES.PST]: new Date(2022, 0, 1, 0, 0, 0), // January 1, 2022 at 00:00:00
[TIMEZONES.EST]: new Date(2022, 0, 1, 0, 0, 0), // January 1, 2022 at 00:00:00
[TIMEZONES.CST]: new Date(2022, 0, 1, 0, 0, 0), // January 1, 2022 at 00:00:00
[TIMEZONES.MST]: new Date(2022, 0, 1, 0, 0, 0), // January 1, 2022 at 00:00:00
[TIMEZONES.JST]: new Date(2022, 0, 1, 0, 0, 0), // January 1, 2022 at 00:00:00
};
export const parsableTZOffset = (input: SupportedTimezones) => {
// using NON_DAYLIGHT_SAVINGS_TIME_DATE is to default all regions to use Standard versus Daylight time
const offset = getTimezoneOffset(input, TIMEZONE_TO_NON_DAYLIGHT_SAVINGS_DATE[input]) / MILLISECONDS_IN_HOUR;
const isNegativeOffset = offset < 0;
const absoluteOffset = Math.abs(offset);
const hours = Math.floor(absoluteOffset);
const minutes = Math.round((absoluteOffset % 1) * 60);
const displayMinutes = String(minutes).padStart(2, '0');
const displayHours = String(hours).padStart(2, '0');
return isNegativeOffset ? `-${displayHours}${displayMinutes}` : `${displayHours}${displayMinutes}`;
}; Test Casesdescribe(parsableTZOffset, () => {
it.each<[SupportedTimezones, string]>([
['EST', '-0500'], // Eastern Standard Time (EST) offset from UTC: -5 hours
['CST', '-0600'], // Pacific Standard Time (PST) offset: -6 hours
['MST', '-0700'], // Mountain Standard Time (PST) offset: -7 hours
['PST', '-0800'], // Pacific Standard Time (PST) offset: -8 hours
['JST', '0900'], // Japanese Standard Time (PST) offset: +9 hours
])('should return the correct timezone offset for %s', (timezone, expectedOffset) => {
expect(parsableTZOffset(timezone)).toBe(expectedOffset);
});
}); Error (When run through extension)
Passing (when run through console) |
Environment
node -v
: v10.13.0npm -v
: 6.4.1npm ls jest
ornpm ls react-scripts
(if you haven’t ejected):$ npm ls jest
jest_vscode_failing_example_app@1.0.0 C:\MyExperiments\jest_vscode_failing_example_app
`-- jest@22.4.4
(also tried 23.6.0 with the same results)
your vscode-jest settings if customized:
Operating system: Windows 10 Version 1803 (OS Build 17134.407)
Prerequisite
npm run test
ornode_modules/.bin/jest
) npm run testSteps to Reproduce
https://github.com/unfalse/vscode_jest_fail
Relevant Debug Info
This is the messages from the output window.
Expected Behavior
vscode-jest is not failing on tests.
Actual Behavior
vscode-jest failing on tests but
npm run test
works fine.The text was updated successfully, but these errors were encountered: