-
Notifications
You must be signed in to change notification settings - Fork 75
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
[Question] How to retrieve current test name in jest-circus? #137
Comments
Oops I think this is explained in the readme. My bad. |
@aesyondu |
Hi @hananmalka, I was referring to the readme of jest-circus It is explained there how to bind to events: import {Event, State} from 'jest-circus';
import NodeEnvironment from 'jest-environment-node';
class MyCustomEnvironment extends NodeEnvironment {
//...
async handleTestEvent(event: Event, state: State) {
if (event.name === 'test_start') {
// ...
}
}
} Therefore, in order to get the current test name, I used something like this: // CustomEnvironment.js
const fs = require("fs");
const PlaywrightEnvironment = require("jest-playwright-preset/lib/PlaywrightEnvironment")
.default;
class CustomEnvironment extends PlaywrightEnvironment {
async setup() {
await super.setup();
// Your setup
}
async teardown() {
// Your teardown
await super.teardown();
}
async handleTestEvent(event) {
if (event.name === "test_start") {
let testNames = [];
let currentTest = event.test;
while (currentTest) {
testNames.push(currentTest.name);
currentTest = currentTest.parent;
}
}
// etc...
}
}
module.exports = CustomEnvironment; |
Oops I think I referenced the jest-playwright readme itself, not the jest-circus one: https://github.com/playwright-community/jest-playwright#usage-with-custom-testenvironment EDIT: Either way, the general idea is the same. |
I'm just wondering if there is a way to use jest-Playwright custom runner
to support jasmine Since currently I'm always get that jasmine is undefined.
I just copy paste the custom runner from the Readme, and try to use
jest-allure2
And keep getting the above error.
…On Sun, Jan 17, 2021, 14:30 aesyondu ***@***.***> wrote:
Oops I think I referenced the jest-playwright readme itself, not the
jest-circus one:
https://github.com/playwright-community/jest-playwright#usage-with-custom-testenvironment
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#137 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADSKSCLLGWRTE7WHBYEDXU3S2LJ6ZANCNFSM4NX77R2Q>
.
|
Ah I see, hmm, I'm not really sure. Have you tried this? zaqqaz/jest-allure#8 (comment)
Sorry I'm not too familiar with using jasmine with jest-playwright. |
Yes...tried this one. It's not working :( |
I mentioned here how I retrieve the current test name when using the jasmine runner.
Now I've updated jest-playwright-preset to 0.2.3 and noted that I'm getting an error:
I noticed that in the 0.2.0 release the jest-circus became the default runner, which is probably the cause of the error. I'm currently searching for it but I don't suppose anyone knows how to retrieve the current test name in the jest-circus runner?
For reference, this is how I currently do it:
So I'm actually using it to do two things:
The text was updated successfully, but these errors were encountered: