-
Notifications
You must be signed in to change notification settings - Fork 46
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
Running w/out Jest prevents consistent filenames #149
Comments
Hi @therealpecus, I am not sure what would be the best approach for unique ID generation. There is already an incremental test ID generation in place but I think for anything more sophisticated you need to have your own ID generator as part of your test and pass the test name to Differencify somehow e.g.
|
Hi @NimaSoroush thanks for your reply. There is an issue with the current code, whereas the internal See this relevant snippet: Lines 232 to 240 in 5ec7eef
The else adds the testId even when the testConfig.testName has been provided. It happens even when testId is undefined , because of:Line 60 in 5ec7eef
which returns NaN which in turns evaluates to true .
Running unchained allows to bypass this test. We already generate unique test names for each test, and pass it as a config to const asyncTest = async ([vid, breakpoint, filename, width, height, title], current = 'N/A', total = 'N/A') => {
// avoid Differencify chaining to ensure test filenames are not polluted by ids
const target = differencify.init({ testName: `${vid}-${width}`, chain: false });
const page = await target.newPage();
await page.setViewport({ width, height });
await page.goto(`http://localhost:3000/_variants/${theme}/${filename}.html`, { waitUntil: 'networkidle2' });
const image = await page.screenshot();
// override filenames including a test counter
target.testConfig.isJest = false;
differencify.testId = undefined;
target.testConfig.testId = undefined;
const test = await target.toMatchSnapshot(image);
console.info(
`[${String(current).padStart(String(total).length)}/${total}] ${
test ? '✅' : '❌'
} ${title} 'http://localhost:3000/_variants/${theme}/${filename}.html' (${breakpoint})`
);
await page.close();
}; We solved it by explicitely dropping out of Jest, and nullying both the global |
Hi @therealpecus , Sorry for the confusion. Yes, you are right and this needs to be fixed. Are you happy putting a fix for this? otherwise, I will prioritize a fix for at some point |
Sure! I'll make a PR. |
Hi!
We have over 6000 tests to run and are avoiding Jest since it adds an unbereable overhead.
Running without Jest prevents consistent test names, since the testId is automatically added.
The responsibility of the test name being unique should be in the hands of the implementator for manual tests, since changing the order of tests invalidates them (the original snapshot would not be found).
Is there a quick workaround?
Tx,
M
The text was updated successfully, but these errors were encountered: