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

Update to chai@5 instead of @esm-bundle/chai #2795

Open
wants to merge 8 commits into
base: next
Choose a base branch
from

Conversation

koddsson
Copy link
Member

@koddsson koddsson commented May 13, 2024

I would like to update to chai@5 as a replacement for @esm-bundle/chai. I additionally needed to upgrade sinon-chai. sinon-chai is currently in a prerelease phase so I updated to that one. If this canary release goes well we can make a PR to master and communicate that the prerelease of sinon-chai is working as expected to the chai maintainers.

Copy link

changeset-bot bot commented May 13, 2024

🦋 Changeset detected

Latest commit: 1b468ab

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@open-wc/building-utils Major
@open-wc/testing Major
@open-wc/building-rollup Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@koddsson koddsson changed the base branch from master to next May 13, 2024 13:51
@CLAassistant
Copy link

CLAassistant commented May 13, 2024

CLA assistant check
All committers have signed the CLA.

@@ -9,7 +8,13 @@ const { startDevServer } = require('@web/dev-server');

const rootDir = path.resolve(__dirname, '..', 'dist');

describe('integration tests', () => {
describe('integration tests', async () => {
let expect;
Copy link
Member

Choose a reason for hiding this comment

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

cant we just

const { expect } = await import('chai');

instead of doing it in a before block?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was doing that before but had to change to this because I was getting silent failures in mocha. Some googling around brought me to mochajs/mocha#2975 (comment) which seemed to indicate that wrapping it in a before would fix the issue. And it seems to fix it for me.

Copy link
Member

Choose a reason for hiding this comment

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

wow TIL, thats wild

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 bit weird. This can then all be removed once this is all ESM.

describe('integration tests', async () => {
let expect;
before(async () => {
const chai = await import('chai');
Copy link
Contributor

Choose a reason for hiding this comment

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

({expect}=async import(‘chai’));?

Copy link
Member Author

Choose a reason for hiding this comment

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

Happy to do this if you have a strong opinion but if it's ok I'll leave this for now. There's once place at least where we need to call chai.use(..) in between anyways and I think we can stop doing this in a before once we are using ESM anyways.

Copy link
Contributor

Choose a reason for hiding this comment

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

Separately, does @open-wc/testing do this for consumers, already? Or will this be a requirement to migrating?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker. Mainly pointing it out in the case end users need to do this every time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah we do this for consumers. We load up all the plugins and then return a instance of chai with those loaded. Found a issue with chai while checking that out that we gotta fix before landing this: https://github.com/open-wc/open-wc/pull/2795/files#r1599496849

import { chaiDomDiff } from '@open-wc/semantic-dom-diff';

window.chai.use(chaiDomDiff);
chai.use(chaiDomDiff);
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 needs to be const chai = use(chaiDomDiff); actually.

chaijs/chaijs.github.io#206 (review)

@@ -2,7 +2,7 @@
import { chaiDomDiff } from '@open-wc/semantic-dom-diff';
import { chaiA11yAxe } from 'chai-a11y-axe';

import chai from '@esm-bundle/chai';
import * as chai from 'chai';
Copy link
Member Author

Choose a reason for hiding this comment

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

Running into chaijs/chai#1603 when trying to register all the plugins further down in this file. It needs to be fixed before we can land this PR.

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.

None yet

4 participants