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

Add guide on using Chai with ESM and plugins #206

Merged
merged 3 commits into from
May 15, 2024
Merged

Conversation

koddsson
Copy link
Member

@koddsson koddsson commented May 2, 2024

This pull request introduces a comprehensive guide on using Chai with ECMAScript Modules (ESM) and plugins, specifically focusing on the chai-http plugin and best practices for plugin authors to expose globals sustainably.

  • Adds a new guide: A detailed guide titled "Using Chai with ESM and Plugins" is added, covering how to import Chai, use plugins like chai-http, and the nuances of importing vs. using globals across files.
  • Updates the Guide Index: The _guides/index.md file is updated to include a link to the new guide under the "Basics" section, ensuring easy access for users looking to integrate Chai with ESM and plugins.
  • Expands on Making Plugins: Within the "Making Plugins" section of _guides/index.md, a new subsection is introduced, offering guidance to plugin authors on how to expose globals in a sustainable manner, with examples of good and potentially problematic practices.

See chaijs/chai#1569 (comment)


For more details, open the Copilot Workspace session.

@koddsson koddsson marked this pull request as ready for review May 2, 2024 07:44
_guides/index.md Outdated Show resolved Hide resolved
Copy link

@43081j 43081j left a comment

Choose a reason for hiding this comment

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

good work here!

it may be worth mentioning, if we continue supporting root mutation, that you now need to use the return value:

import {use} from 'chai';
import somePlugin from 'chai-whatever';

const chai = use(somePlugin);

chai.somePluginRootExport();

@koddsson
Copy link
Member Author

Figured I'd piggy-back on this PR to land some docs for chaijs/chai#1617 as well.

@koddsson koddsson merged commit 01eb070 into master May 15, 2024
@koddsson koddsson deleted the koddsson/add-esm-guide branch May 15, 2024 06:19
koddsson added a commit that referenced this pull request May 15, 2024
This reverts commit 01eb070, reversing
changes made to 9fffbc6.
koddsson pushed a commit that referenced this pull request May 15, 2024
Revert "Merge pull request #206 from chaijs/koddsson/add-esm-guide"
koddsson pushed a commit that referenced this pull request May 15, 2024
Add guide on using Chai with ESM and plugins
koddsson added a commit that referenced this pull request May 16, 2024
This reverts commit 01eb070, reversing
changes made to 9fffbc6.
koddsson pushed a commit that referenced this pull request May 16, 2024
Add guide on using Chai with ESM and plugins
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.

2 participants