Skip to content

Commit

Permalink
chore: replace @esm-bundle/chai with regular chai package
Browse files Browse the repository at this point in the history
Closes #2633
  • Loading branch information
jonkoops committed Feb 3, 2024
1 parent f7fcf29 commit edd07e7
Show file tree
Hide file tree
Showing 68 changed files with 222 additions and 93 deletions.
10 changes: 5 additions & 5 deletions docs/blog/introducing-web-test-runner/index.md.review
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ This is the minimal instruction on how to start using the web test runner.
1. Install the necessary packages

```
npm i --save-dev @web/test-runner @esm-bundle/chai
npm i --save-dev @web/test-runner chai
```

2. Add a script to your `package.json`
Expand All @@ -50,7 +50,7 @@ This is the minimal instruction on how to start using the web test runner.
3. Create a test file `test/sum.test.js`.

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { sum } from '../src/sum.js';

it('sums up 2 numbers', () => {
Expand Down Expand Up @@ -189,7 +189,7 @@ npm i --save-dev @web/test-runner-commands
With that, we get a `setViewport` method which we can use.

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { setViewport } from '@web/test-runner-commands';
import { isMobile } from '../src/isMobile';

Expand Down Expand Up @@ -236,7 +236,7 @@ See more instructions in the [Code Coverage Guide](../../guides/test-runner/code
First, we need to install the required dependencies:

```
npm i --save-dev @web/test-runner @esm-bundle/chai @types/mocha typescript
npm i --save-dev @web/test-runner chai @types/mocha typescript
```

Add the `src/sum.ts` file:
Expand All @@ -254,7 +254,7 @@ export function sum(...numbers: number[]) {
Add the `test/sum.test.ts` file:

```ts
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { sum } from '../src/sum.js';

it('sums up 2 numbers', () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/dev-server/plugins/import-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ When the plugin is installed any import maps found in HTML files are used to res
<script type="importmap">
{
"imports": {
"chai": "/node_modules/@esm-bundle/chai/chai.js",
"chai": "/node_modules/chai/chai.js",
"./app.js": "./mocked-app.js"
}
}
Expand All @@ -74,7 +74,7 @@ When the plugin is installed any import maps found in HTML files are used to res

<body>
<script type="module">
// mapped to /node_modules/@esm-bundle/chai/chai.js
// mapped to /node_modules/chai/chai.js
import chai from 'chai';
// mapped to ./mocked-app.js
import app from './app.js';
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/test-runner/writing-tests/helper-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ Not all helper libraries ship es modules which are usable in the browser. On thi

## Assertions

[chai](https://www.npmjs.com/package/chai) is a popular assertion library. It doesn't ship an es module, but you can use [@esm-bundle/chai](https://www.npmjs.com/package/@esm-bundle/chai) for that.
[chai](https://www.npmjs.com/package/chai) is a popular assertion library.

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';

expect(undefined).to.not.be.a('function');
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/test-runner/writing-tests/html-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ With mocha, you need to define your tests inside the `runTests` function:
<body>
<script type="module">
import { runTests } from '@web/test-runner-mocha';
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
runTests(async () => {
// write your tests inline
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/test-runner/writing-tests/js-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Javascript files are loaded by the test framework that is configured. The defaul
For example:

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { myFunction } from '../src/myFunction.js';

describe('myFunction', () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/test-runner/writing-tests/mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Test file:
<body>
<script type="module">
import { runTests } from '@web/test-runner-mocha';
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
// import inside will resolve to ./mocks/postData.js
import { sendMessage } from '../src/sendMessage.js';
// resolves to ./mocks/postData.js
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/test-runner/code-coverage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ As good citizens we start with the tests first
👉 `test/calc.test.js`

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { calc } from '../src/calc.js';

it('does plus for 2 numbers', () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/test-runner/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Now that we know what we want we need to place this file somewhere and run a too
1. Install the necessary packages

```
npm i --save-dev @web/test-runner @esm-bundle/chai
npm i --save-dev @web/test-runner chai
```

2. Add a script to your `package.json`
Expand Down Expand Up @@ -56,7 +56,7 @@ fair enough - we didn't create a test file yet.
1. Take the spec/test from above and create a test file `test/sum.test.js`.

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { sum } from '../src/sum.js';

it('sums up 2 numbers', () => {
Expand Down
4 changes: 2 additions & 2 deletions docs/guides/test-runner/responsive.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ npm i --save-dev @web/test-runner-commands
With that we get a `setViewport` method which we can put to good use.

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { setViewport } from '@web/test-runner-commands';
import { isMobile } from '../src/isMobile';

Expand Down Expand Up @@ -110,7 +110,7 @@ Next, we can write our tests to change the viewport and check if our media queri

<script type="module">
import { runTests } from '@web/test-runner-mocha';
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { setViewport } from '@web/test-runner-commands';
runTests(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/test-runner/watch-and-debug/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ We want to be able to pass in a string like `1 + 2 + 3` to get its sum.
👉 `test/calc.test.js`

```js
import { expect } from '@esm-bundle/chai';
import { expect } from 'chai';
import { calc } from '../src/calc.js';

it('calculates sums', () => {
Expand Down
2 changes: 1 addition & 1 deletion integration/test-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"@web/test-runner-core": "^0.13.0"
},
"devDependencies": {
"@esm-bundle/chai": "^4.1.5"
"chai": "^5.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<body>
<script type="module">
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';
import { runTests } from '../../../../../packages/test-runner-mocha/dist/standalone.js';

runTests(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

describe('basic test', () => {
it('works', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('supports object spread', () => {
const foo = { a: 1 };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';
import module from './module-features-a.js';

it('supports static imports', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

describe('timers test', () => {
it('can call setTimeout', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

describe('basic test', () => {
it('works', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

describe('basic test', () => {
it('works', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('can run a test with focus a', async () => {
const input = document.createElement('input');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('can run a test with focus b', async () => {
const input = document.createElement('input');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('can run a test with focus c', async () => {
const input = document.createElement('input');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('can run a test with focus d', async () => {
const input = document.createElement('input');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('can run a test with focus e', async () => {
const input = document.createElement('input');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

afterEach(() => {
throw new Error('error thrown in afterEach hook');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

after(() => {
throw new Error('error thrown in after hook');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

beforeEach(() => {
throw new Error('error thrown in beforeEach hook');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

before(() => {
throw new Error('error thrown in before hook');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('bad predicate', function() {
const fixture = { x: 'x' }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

throw new Error('This is thrown before running tests');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';
import './shared-a.js';

it('object diff A', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { expect } from '../../../../../node_modules/@esm-bundle/chai/esm/chai.js';
import { expect } from '../../../../../node_modules/chai/chai.js';

it('string diff', () => {
expect('foo').to.equal('bar');
Expand Down

0 comments on commit edd07e7

Please sign in to comment.