Skip to content
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

Use more helper runner helper methods #421

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

camillobruni
Copy link
Contributor

@camillobruni camillobruni commented Aug 22, 2024

Refactor the runner a bit to be more flexible for upcoming experimental PRs.

@bgrins bgrins requested a review from julienw August 23, 2024 16:03
};
frame.src = `${suite.url}`;
frame.onload = () => resolve();
frame.onerror = () => reject();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


it("should call prepare on all suites", () => {
for (const suite in runner.suites)
suite.prepare.calledOnce();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this is working. I think calledOnce is a property on a spy, not a function?
You probably wanted assert.calledOnce(suite.prepare). This makes me wonder if we really execute this line.

Debugging further it looks like indeed runner.suites is undefined, that's why the test passes (the for loop never runs anything). For loops are dangerous in tests :-)
I think you wanted _suites, not suites (also above in the before). I tried this but then I get more errors, so I'll let you debug :-D

Also it would be good to add something such as expect(runner._suites).not.to.have.length(0) to make sure we enter the loop.

@bgrins bgrins requested a review from rniwa August 28, 2024 18:18
// seed. This is not a high quality RNG, but it's plenty good enough.
for (let i = 0; i < suites.length - 1; i++) {
let j = i + (this._suiteOrderRandomNumberGenerator() % (suites.length - i));
let tmp = suites[i];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use const maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants