-
Notifications
You must be signed in to change notification settings - Fork 6
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
Allow being used inside Jest beforeAll #72
Comments
solve by moving |
Hey thanks for posting this - cft should emit a better error in this case. The error should indicate what is being done wrong. Marking as accepting PRs. |
Hi, after investigating, this change is quite annoying for us. This is what we expect from
Our implementation for (1) looked like this in our const allowConsoleDefaultConfig = {
debug: false,
error: false,
log: false,
warn: false,
}
let allowConsoleRuntimeConfig = Object.assign({}, allowConsoleDefaultConfig)
global.allowConsole = function (config = allowConsoleDefaultConfig) {
allowConsoleRuntimeConfig = Object.assign({}, allowConsoleDefaultConfig, config)
}
global.beforeAll(() => {
consoleFailTestModule.cft({
testFramework: 'jest',
spyLibrary: 'jest',
console: allowConsoleRuntimeConfig,
})
}) Our implementation for (2) is using the allowConsole({ error: true }) Since it is not possible after If you have any clue how we can fix this, that would be much appreciated as our global suite of tests depend on this. |
Hello @JoshuaKGoldberg , this is blocking the jest 26 to 27 upgrade, do you have any indication that could help us move forward? |
I took a deeper look at how this gets run in pass-culture/pass-culture-app-native#3306, as mentioned in #64 (comment). If you're interested you should be able to modify Right now, the Jest environment code calls to the global Jest return {
after(callback: (afterHooks: TestAfterHooks) => void) {
afterEach(() => {
callback({
reportComplaint({ error }) {
throw error;
},
});
});
},
// ...
}; That I'm betting you could modify the code to something like: const afterEachCallback = [() => {}];
afterEach(() => {
afterEachCallback[0]();
});
return {
after(callback: (afterHooks: TestAfterHooks) => void) {
afterEachCallback[0] = () => callback({
reportComplaint({ error }) {
throw error;
}
});
},
// ...
}; That's just a sketch. I don't have the time to do this myself as your usage pattern isn't one I've come across or needed to use in any of my projects. But this issue is marked as |
Thank you for the detailed explanation. I will take a look tomorrow and let you know for the PR fix. I appreciate that you still try to help during your vacation. One thing, I didn't got why you initialized an array for just a callback function, I'll try without first. |
I just opened a PR as it seems to work well : #76 Meanwhile waiting for the release, we'll use a patch-package. |
Hello, we are trying to ugprade jest to latest and encounter issue in our upgrade branch with
consol-fail-test
: pass-culture/pass-culture-app-native#3271example:
It seems it does not support the latest jest version, is there a workaroud to keep using console-fail-test or a way we can help?
The text was updated successfully, but these errors were encountered: