-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
23 lines (21 loc) · 902 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { expect } from 'chai';
import { exec } from 'child_process';
describe('HTTP Client Script', function () {
it('should make a GET request without headers and body', function (done) {
exec('node ./ GET https://lightfulweb.free.beeceptor.com/todos', (error, stdout, stderr) => {
expect(error).to.be.null;
expect(stderr).to.be.empty;
expect(stdout).to.include('Status Code: 200');
done();
});
});
it('should make a POST request with headers and body', function (done) {
exec('node ./ POST https://lightfulweb.free.beeceptor.com/todos -h "Content-Type: application/json" -b \'{"title": "Test Post", "body": "Test Body", "userId": 1}\'', (error, stdout, stderr) => {
expect(error).to.be.null;
expect(stderr).to.be.empty;
expect(stdout).to.include('Status Code: 200');
expect(stdout).to.include('id');
done();
});
});
});