Skip to content

Commit 82715b9

Browse files
committed
chore: make json-server test working
1 parent a2f95ac commit 82715b9

File tree

8 files changed

+78
-83
lines changed

8 files changed

+78
-83
lines changed

__tests__/respect/local-json-server/__ignored_snapshots__/local-json-server.test.ts.ignored-snap renamed to __tests__/respect/local-json-server/__snapshots__/local-json-server.test.ts.snap

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`local-json-server test case 1`] = `
4-
"────────────────────────────────────────────────────────────────────────────────[0m
5-
[0m
6-
Running workflow local-json-server.yaml / before[0m
7-
[0m
8-
✓ GET /items - step get-all-items-before[0m
3+
exports[`local-json-server local-json-server test case 1`] = `
4+
"────────────────────────────────────────────────────────────────────────────────
5+
6+
Running workflow local-json-server.yaml / before
7+
8+
✓ GET /items - step get-all-items-before
99
    ✓ status code check (Response code 200 matches one of description codes: [200])
1010
    ✓ content-type check
1111
    ✓ schema check
12-
[0m
13-
────────────────────────────────────────────────────────────────────────────────[0m
14-
[0m
15-
Running workflow local-json-server.yaml / crud-items[0m
16-
[0m
17-
✓ POST /items - step add-item[0m
12+
13+
────────────────────────────────────────────────────────────────────────────────
14+
15+
Running workflow local-json-server.yaml / crud-items
16+
17+
✓ POST /items - step add-item
1818
    ✓ success criteria check
1919
    ✓ status code check (Response code 201 matches one of description codes: [201])
2020
    ✓ content-type check
2121
    ✓ schema check
22-
[0m
23-
✗ GET /items - step get-all-items-again[0m
22+
23+
✗ GET /items - step get-all-items-again
2424
    ✗ success criteria check
2525
    ✓ status code check (Response code 200 matches one of description codes: [200])
2626
    ✓ content-type check
2727
    ✓ schema check
28-
[0m
29-
✓ GET /items/{id} - step get-item-by-id[0m
28+
29+
✓ GET /items/{id} - step get-item-by-id
3030
    ✓ success criteria check
3131
    ✓ success criteria check
3232
    ✓ success criteria check
3333
    ✓ status code check (Response code 200 matches one of description codes: [200, 404])
3434
    ✓ content-type check
3535
    ✓ schema check
36-
[0m
37-
✓ DELETE /items/{id} - step drop-item[0m
36+
37+
✓ DELETE /items/{id} - step drop-item
3838
    ✓ success criteria check
3939
    ✓ status code check (Response code 200 matches one of description codes: [200])
40-
[0m
41-
✓ GET /items/{id} - step get-after-deleting[0m
40+
41+
✓ GET /items/{id} - step get-after-deleting
4242
    ✓ success criteria check
4343
    ✓ status code check (Response code 404 matches one of description codes: [200, 404])
4444
    ✓ content-type check
45-
[0m
46-
────────────────────────────────────────────────────────────────────────────────[0m
47-
[0m
48-
Running workflow local-json-server.yaml / auto-inherit[0m
49-
[0m
50-
✓ POST /items - step add-item-auto-inherit[0m
45+
46+
────────────────────────────────────────────────────────────────────────────────
47+
48+
Running workflow local-json-server.yaml / auto-inherit
49+
50+
✓ POST /items - step add-item-auto-inherit
5151
    ✓ status code check (Response code 201 matches one of description codes: [201])
5252
    ✓ content-type check
5353
    ✓ schema check
54-
[0m
55-
✓ GET /items - step get-all-items[0m
54+
55+
✓ GET /items - step get-all-items
5656
    ✓ status code check (Response code 200 matches one of description codes: [200])
5757
    ✓ content-type check
5858
    ✓ schema check
59-
[0m
60-
✓ GET /items/{id} - step get-item-by-id-auto-inherit[0m
59+
60+
✓ GET /items/{id} - step get-item-by-id-auto-inherit
6161
    ✓ status code check (Response code 404 matches one of description codes: [200, 404])
6262
    ✓ content-type check
63-
[0m
64-
✓ DELETE /items/{id} - step drop-item-auto-inherit[0m
63+
64+
✓ DELETE /items/{id} - step drop-item-auto-inherit
6565
    ✓ success criteria check
6666
    ✓ status code check (Response code 200 matches one of description codes: [200])
67-
[0m
68-
[0m
67+
68+
6969
  Failed tests info:
70-
[0m
71-
  Workflow name: crud-items[0m
72-
[0m
73-
    stepId - get-all-items-again[0m
74-
    ✗ success criteria check[0m
75-
      Checking simple criteria: {"condition":"$response.body#/0/value == 100"}[0m
76-
      [0m
70+
71+
  Workflow name: crud-items
72+
73+
    stepId - get-all-items-again
74+
    ✗ success criteria check
75+
      Checking simple criteria: {"condition":"$response.body#/0/value == 100"}
76+
      
7777
  Summary for local-json-server.yaml
7878
  
7979
  Workflows: 2 passed, 1 failed, 3 total
8080
  Steps: 9 passed, 1 failed, 10 total
8181
  Checks: 31 passed, 1 failed, 32 total
82-
  Time: <test>ms[0m
83-
[0m
84-
[0m
82+
  Time: <test>ms
83+
84+
8585
┌────────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────┬──────────┬─────────┐
8686
│ Filename │ Workflows │ Passed │ Failed │ Warnings │ Skipped │
8787
├────────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────┼──────────┼─────────┤
8888
│ x local-json-server.yaml │ 3 │ 2 │ 1 │ - │ - │
89-
└────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┴─────────┘[0m
90-
[0m
91-
[0m
89+
└────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┴─────────┘
90+
91+
9292
9393
Tests exited with error
9494
"
Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-
// import { getParams, getCommandOutput } from '../utils';
2-
// import { join } from 'path';
1+
import { spawn } from 'child_process';
2+
import { getParams, getCommandOutput } from '../utils';
3+
import { join } from 'path';
34

4-
// test('local-json-server test case', () => {
5-
// const indexEntryPoint = join(process.cwd(), 'packages/cli/lib/index.js');
6-
// const fixturesPath = join(__dirname, 'local-json-server.yaml');
7-
// const args = getParams(indexEntryPoint, ['respect', fixturesPath]);
5+
describe('local-json-server', () => {
6+
let serverProcess: any;
87

9-
// const result = getCommandOutput(args);
10-
// expect(result).toMatchSnapshot();
11-
// });
8+
beforeAll(async () => {
9+
// Start json-server
10+
serverProcess = spawn('npm', ['run', 'json-server'], { detached: true });
11+
});
1212

13-
test('local-json-server test case', () => {
14-
//TODO: Remove.Disable this test until json-server is added to the e2e flow.
15-
expect(true).toBe(true);
13+
afterAll(() => {
14+
// Kill the process group to ensure child processes are cleaned up
15+
process.kill(-serverProcess.pid);
16+
});
17+
18+
test('local-json-server test case', () => {
19+
const indexEntryPoint = join(process.cwd(), 'packages/cli/lib/index.js');
20+
const fixturesPath = join(__dirname, 'local-json-server.yaml');
21+
const args = getParams(indexEntryPoint, ['respect', fixturesPath]);
22+
23+
const result = getCommandOutput(args);
24+
expect(result).toMatchSnapshot();
25+
});
1626
});

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ module.exports = {
1212
],
1313
coverageThreshold: {
1414
'packages/core/': {
15-
statements: 80,
15+
statements: 84,
1616
branches: 72,
1717
functions: 76,
18-
lines: 80,
18+
lines: 84,
1919
},
2020
'packages/cli/': {
2121
statements: 64,

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"OpenAPI linter",
3131
"Swagger linter",
3232
"AsyncAPI linter",
33+
"Arazzo linter",
3334
"oas"
3435
],
3536
"contributors": [

packages/core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"OpenAPI linter",
2929
"Swagger linter",
3030
"AsyncAPI linter",
31+
"Arazzo linter",
3132
"oas"
3233
],
3334
"contributors": [

packages/respect-core/.env.example

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/respect-core/jest.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/respect-core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
{
22
"name": "@redocly/respect-core",
33
"version": "1.30.0",
4-
"description": "API TEST FRAMEWORK",
5-
"scripts": {
6-
"json-server": "json-server --watch api-samples/fake-db.json --port 3000 --host 0.0.0.0"
7-
},
4+
"description": "API testing framework core",
85
"main": "lib/index.js",
96
"types": "lib/index.d.ts",
107
"exports": {
@@ -25,7 +22,10 @@
2522
},
2623
"homepage": "https://github.com/Redocly/redocly-cli",
2724
"keywords": [
28-
"API Testing"
25+
"API Testing",
26+
"Arazzo",
27+
"OpenAPI",
28+
"contract testing"
2929
],
3030
"contributors": [
3131
"Roman Hotsiy <roman@redocly.com> (https://redocly.com/)"

0 commit comments

Comments
 (0)