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

feat: implementing custom fixture #9

Merged
merged 7 commits into from
Jun 12, 2023
Merged

feat: implementing custom fixture #9

merged 7 commits into from
Jun 12, 2023

Conversation

dlockhart
Copy link
Member

Implementation of a custom fixture() method that extends the open-wc version but recursively waits for nested Lit elements to resolve their updateCompletes.

This doesn't currently include special handling for components that would like fixture to wait even longer (e.g. after an API call is complete), but that can be a future improvement.

@dlockhart dlockhart requested a review from a team as a code owner June 7, 2023 20:33
src/fixture/fixture.js Outdated Show resolved Hide resolved
src/fixture/fixture.js Outdated Show resolved Hide resolved
test/fixture.test.js Outdated Show resolved Hide resolved
@dlockhart dlockhart marked this pull request as draft June 7, 2023 20:37
@dlockhart dlockhart force-pushed the dlockhart/fixture branch from 8300d80 to 0cfd335 Compare June 8, 2023 18:48
src/fixture/fixture.js Outdated Show resolved Hide resolved
src/focus.js Outdated Show resolved Hide resolved
@dlockhart dlockhart marked this pull request as ready for review June 8, 2023 18:50
@dlockhart dlockhart force-pushed the dlockhart/fixture branch 3 times, most recently from b04dc8d to 91c3a7e Compare June 9, 2023 19:08
"exports": {
".": "./src/browser/index.js",
"./wtr-config.js": "./src/server/index.js"
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Had to split the exports since having them all in one file was causing the browser to blow up on Node.js things.

@dlockhart dlockhart force-pushed the dlockhart/fixture branch from 91c3a7e to 311b0ec Compare June 9, 2023 20:29
@@ -715,6 +716,90 @@
}
}
},
"node_modules/@puppeteer/browsers/node_modules/ansi-styles": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it weird that all this puppeteer stuff is being added? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a dependency of @web/test-runner-chrome which is a dependency of @web/test-runner... so not sure why it was ever not here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh yeah, that's super weird. We'll see what the update job does 😓

Copy link
Member Author

Choose a reason for hiding this comment

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

This was the result of me doing a fresh npm install with no lock file, so hopefully it does nothing!

package.json Outdated Show resolved Hide resolved
src/browser/reset.js Outdated Show resolved Hide resolved
@bearfriend

This comment was marked as resolved.


afterEach(() => restore());

describe('reset', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests make me super excited to get to use this new fixture!

await waitUntil(() => resolves.has('elem1'));
const timeout = setTimeout(() => resolves.get('elem1')(), 50);
const finished = await finishedPromise;
clearTimeout(timeout);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to clear the timeout?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not necessary when everything is working correctly, but when things start to go wrong -- like if finishedPromise resolves before the code in the timeout executes -- then the test can fail (as it should) but then the code in the timeout executes during the NEXT test.

But explaining this out gave me an idea to clean them up in afterEach which should also make it clear why it's needed, so I'll make that change now!

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome, yeah I like that much better!

@dlockhart dlockhart force-pushed the dlockhart/fixture branch from 42586c6 to ee8bde1 Compare June 12, 2023 13:17
@dlockhart dlockhart enabled auto-merge (squash) June 12, 2023 13:17
@dlockhart dlockhart merged commit 92af4cf into main Jun 12, 2023
@dlockhart dlockhart deleted the dlockhart/fixture branch June 12, 2023 13:18
@ghost
Copy link

ghost commented Jun 12, 2023

🎉 This PR is included in version 0.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@ghost ghost added the released label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants