Skip to content

Commit

Permalink
build: remove simplifyify from build process
Browse files Browse the repository at this point in the history
test: updated index.html for future browser tests
build: delete old build files in dist folder
docs: update to new ESM usage and update browser use
docs: update small typos and update a few urls
  • Loading branch information
Trickfilm400 committed Apr 13, 2024
1 parent f1fc3f2 commit 5f7e05d
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 12,936 deletions.
2 changes: 1 addition & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@semantic-release/npm",
"@semantic-release/github",
["@semantic-release/git", {
"assets": ["dist/*", "package.json", "CHANGELOG.md", "package-lock.json"],
"assets": ["package.json", "CHANGELOG.md", "package-lock.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}]
],
Expand Down
53 changes: 24 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,13 @@ This is an addon plugin for the [Chai Assertion Library](https://www.chaijs.com/
Use this plugin as you would all other Chai plugins.

```js
const chai = require('chai');
const chaiHttp = require('chai-http');
import chaiModule from "chai";
import chaiHttp from "chai-http";

chai.use(chaiHttp);
const chai = chaiModule.use(chaiHttp);
```

To use Chai HTTP on a web page, just include the [`dist/chai-http.js`](dist/chai-http.js) file:

```html
<script src="chai.js"></script>
<script src="chai-http.js"></script>
<script>
chai.use(chaiHttp);
</script>
```
To use Chai HTTP on a web page, please use the latest v4 version for now.

## Integration Testing

Expand All @@ -57,7 +49,7 @@ port to listen on for a given test.
__Note:__ This feature is only supported on Node.js, not in web browsers.

```js
chai.request(app)
chai.request.execute(app)
.get('/')
```

Expand All @@ -68,7 +60,7 @@ keep the server open, perhaps if you're making multiple requests, you must call
`.keepOpen()` after `.request()`, and manually close the server down:

```js
const requester = chai.request(app).keepOpen()
const requester = chai.request.Request(app).keepOpen()

Promise.all([
requester.get('/a'),
Expand All @@ -84,7 +76,7 @@ Promise.all([
You may also use a base url as the foundation of your request.

```js
chai.request('http://localhost:8080')
chai.request.execute('http://localhost:8080')
.get('/')
```

Expand All @@ -106,7 +98,7 @@ Examples:
`.set()`
```js
// Set a request header
chai.request(app)
chai.request.execute(app)
.put('/user/me')
.set('Content-Type', 'application/json')
.send({ password: '123', confirmPassword: '123' })
Expand All @@ -115,15 +107,15 @@ chai.request(app)
`.send()`
```js
// Send some JSON
chai.request(app)
chai.request.execute(app)
.put('/user/me')
.send({ password: '123', confirmPassword: '123' })
```

`.type()`
```js
// Send some Form Data
chai.request(app)
chai.request.execute(app)
.post('/user/me')
.type('form')
.send({
Expand All @@ -136,20 +128,20 @@ chai.request(app)
`.attach()`
```js
// Attach a file
chai.request(app)
chai.request.execute(app)
.post('/user/avatar')
.attach('imageField', fs.readFileSync('avatar.png'), 'avatar.png')
```

`.auth()`
```js
// Authenticate with Basic authentication
chai.request(app)
chai.request.execute(app)
.get('/protected')
.auth('user', 'pass')

// Authenticate with Bearer Token
chai.request(app)
chai.request.execute(app)
.get('/protected')
.auth(accessToken, { type: 'bearer' })

Expand All @@ -158,7 +150,7 @@ chai.request(app)
`.query()`
```js
// Chain some GET query parameters
chai.request(app)
chai.request.execute(app)
.get('/search')
.query({name: 'foo', limit: 10}) // /search?name=foo&limit=10
```
Expand All @@ -174,7 +166,7 @@ const { expect } = chai;
To make the request and assert on its response, the `end` method can be used:

```js
chai.request(app)
chai.request.execute(app)
.put('/user/me')
.send({ password: '123', confirmPassword: '123' })
.end((err, res) => {
Expand All @@ -197,7 +189,7 @@ callback has completed, and the assertions can be verified:

```js
it('fails, as expected', function(done) { // <= Pass in done callback
chai.request('http://localhost:8080')
chai.request.execute('http://localhost:8080')
.get('/')
.end((err, res) => {
expect(res).to.have.status(123);
Expand All @@ -206,7 +198,7 @@ it('fails, as expected', function(done) { // <= Pass in done callback
});

it('succeeds silently!', () => { // <= No done callback
chai.request('http://localhost:8080')
chai.request.execute('http://localhost:8080')
.get('/')
.end((err, res) => {
expect(res).to.have.status(123); // <= Test completes before this runs
Expand All @@ -224,7 +216,7 @@ If `Promise` is available, `request()` becomes a Promise capable library -
and chaining of `then`s becomes possible:

```js
chai.request(app)
chai.request.execute(app)
.put('/user/me')
.send({ password: '123', confirmPassword: '123' })
.then((res) => {
Expand All @@ -246,10 +238,13 @@ requiring in chai-http. For example:
```js
// Add promise support if this does not exist natively.
if (!global.Promise) {
global.Promise = require('q');
global.Promise = await import('q');
}
const chai = require('chai');
chai.use(require('chai-http'));

import chaiModule from "chai"
import chaiHttp from "chai-http"

const chai = chaiModule.use(chaiHttp);
```

#### Retaining cookies with each request
Expand Down
Loading

0 comments on commit 5f7e05d

Please sign in to comment.