@opra/testing 1.0.0-alpha.3 → 1.0.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/api-expect/api-expect-collection.js +3 -3
- package/cjs/api-expect/api-expect-error.js +2 -1
- package/cjs/api-expect/api-expect.js +1 -1
- package/cjs/test-backend.js +1 -1
- package/cjs/utils/object-matches.util.js +3 -3
- package/esm/api-expect/api-expect-collection.js +1 -1
- package/esm/api-expect/api-expect-error.js +2 -1
- package/esm/api-expect/api-expect.js +1 -1
- package/esm/test-backend.js +1 -1
- package/esm/test-client.js +1 -1
- package/esm/utils/object-matches.util.js +2 -1
- package/package.json +10 -6
- package/types/test-backend.d.ts +1 -2
- package/types/test-client.d.ts +1 -2
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ApiExpectCollection = void 0;
|
|
4
|
+
exports.convertFilter = convertFilter;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
|
-
const rule_judgment_1 = tslib_1.__importDefault(require("rule-judgment"));
|
|
6
6
|
const type_is_1 = tslib_1.__importDefault(require("@browsery/type-is"));
|
|
7
7
|
const common_1 = require("@opra/common");
|
|
8
|
+
const rule_judgment_1 = tslib_1.__importDefault(require("rule-judgment"));
|
|
8
9
|
const api_expect_base_js_1 = require("./api-expect-base.js");
|
|
9
10
|
// @ts-ignore
|
|
10
11
|
const ruleJudgment = typeof rule_judgment_1.default === 'object' ? rule_judgment_1.default.default : rule_judgment_1.default;
|
|
@@ -254,4 +255,3 @@ function convertFilter(str) {
|
|
|
254
255
|
}
|
|
255
256
|
throw new Error(`${ast.kind} is not implemented yet`);
|
|
256
257
|
}
|
|
257
|
-
exports.convertFilter = convertFilter;
|
|
@@ -9,8 +9,9 @@ class ApiExpectError extends api_expect_base_js_1.ApiExpectBase {
|
|
|
9
9
|
try {
|
|
10
10
|
if (typeof expected === 'string')
|
|
11
11
|
expected = { message: expected };
|
|
12
|
-
else if (expected instanceof RegExp)
|
|
12
|
+
else if (expected instanceof RegExp) {
|
|
13
13
|
expected = { message: expect.stringMatching(expected) };
|
|
14
|
+
}
|
|
14
15
|
else
|
|
15
16
|
expected = (0, common_1.omitNullish)(expected);
|
|
16
17
|
this._expect(this.response.body.errors).toEqual(expect.arrayContaining([expect.objectContaining(expected)]));
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ApiExpect = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
require("../jest-extend/index.js");
|
|
6
|
-
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
7
6
|
const common_1 = require("@opra/common");
|
|
7
|
+
const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
8
8
|
const api_expect_base_js_1 = require("./api-expect-base.js");
|
|
9
9
|
const api_expect_collection_js_1 = require("./api-expect-collection.js");
|
|
10
10
|
const api_expect_error_js_1 = require("./api-expect-error.js");
|
package/cjs/test-backend.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TestBackend = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const http_1 = require("http");
|
|
6
5
|
const path = tslib_1.__importStar(require("node:path"));
|
|
7
6
|
const client_1 = require("@opra/client");
|
|
7
|
+
const http_1 = require("http");
|
|
8
8
|
const api_expect_js_1 = require("./api-expect/api-expect.js");
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.objectMatches =
|
|
3
|
+
exports.objectMatches = objectMatches;
|
|
4
4
|
function objectMatches(received, expected) {
|
|
5
5
|
_objectMatches(received, expected, '');
|
|
6
6
|
}
|
|
7
|
-
exports.objectMatches = objectMatches;
|
|
8
7
|
function _objectMatches(received, expected, path) {
|
|
9
8
|
if (typeof received !== typeof expected)
|
|
10
9
|
expect(typeof received).toStrictEqual('object');
|
|
@@ -23,12 +22,13 @@ function _objectMatches(received, expected, path) {
|
|
|
23
22
|
else if (ev && typeof ev === 'object') {
|
|
24
23
|
_objectMatches(rv, ev, path ? path + '.' + k : k);
|
|
25
24
|
}
|
|
26
|
-
else
|
|
25
|
+
else {
|
|
27
26
|
try {
|
|
28
27
|
expect(rv).toEqual(ev);
|
|
29
28
|
}
|
|
30
29
|
catch {
|
|
31
30
|
throw new Error(`Property "${k}" does not match`);
|
|
32
31
|
}
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import ruleJudgmentLib from 'rule-judgment';
|
|
2
1
|
import typeIs from '@browsery/type-is';
|
|
3
2
|
import { MimeTypes, omitNullish, OpraFilter } from '@opra/common';
|
|
3
|
+
import ruleJudgmentLib from 'rule-judgment';
|
|
4
4
|
import { ApiExpectBase } from './api-expect-base.js';
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
const ruleJudgment = typeof ruleJudgmentLib === 'object' ? ruleJudgmentLib.default : ruleJudgmentLib;
|
|
@@ -6,8 +6,9 @@ export class ApiExpectError extends ApiExpectBase {
|
|
|
6
6
|
try {
|
|
7
7
|
if (typeof expected === 'string')
|
|
8
8
|
expected = { message: expected };
|
|
9
|
-
else if (expected instanceof RegExp)
|
|
9
|
+
else if (expected instanceof RegExp) {
|
|
10
10
|
expected = { message: expect.stringMatching(expected) };
|
|
11
|
+
}
|
|
11
12
|
else
|
|
12
13
|
expected = omitNullish(expected);
|
|
13
14
|
this._expect(this.response.body.errors).toEqual(expect.arrayContaining([expect.objectContaining(expected)]));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../jest-extend/index.js';
|
|
2
|
-
import colors from 'ansi-colors';
|
|
3
2
|
import { MimeTypes } from '@opra/common';
|
|
3
|
+
import colors from 'ansi-colors';
|
|
4
4
|
import { ApiExpectBase } from './api-expect-base.js';
|
|
5
5
|
import { ApiExpectCollection } from './api-expect-collection.js';
|
|
6
6
|
import { ApiExpectError } from './api-expect-error.js';
|
package/esm/test-backend.js
CHANGED
package/esm/test-client.js
CHANGED
|
@@ -19,12 +19,13 @@ function _objectMatches(received, expected, path) {
|
|
|
19
19
|
else if (ev && typeof ev === 'object') {
|
|
20
20
|
_objectMatches(rv, ev, path ? path + '.' + k : k);
|
|
21
21
|
}
|
|
22
|
-
else
|
|
22
|
+
else {
|
|
23
23
|
try {
|
|
24
24
|
expect(rv).toEqual(ev);
|
|
25
25
|
}
|
|
26
26
|
catch {
|
|
27
27
|
throw new Error(`Property "${k}" does not match`);
|
|
28
28
|
}
|
|
29
|
+
}
|
|
29
30
|
}
|
|
30
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/testing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.30",
|
|
4
4
|
"description": "Opra testing package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,9 +17,10 @@
|
|
|
17
17
|
"build:esm": "tsc -b tsconfig-build-esm.json",
|
|
18
18
|
"postbuild": "cp README.md package.json ../../LICENSE ../../build/testing && cp ../../package.cjs.json ../../build/testing/cjs/package.json",
|
|
19
19
|
"lint": "eslint . --max-warnings=0",
|
|
20
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
20
21
|
"format": "prettier . --write --log-level=warn",
|
|
21
|
-
"test": "jest",
|
|
22
|
-
"cover": "jest --collect-coverage",
|
|
22
|
+
"test": "jest --passWithNoTests",
|
|
23
|
+
"cover": "jest --passWithNoTests --collect-coverage",
|
|
23
24
|
"clean": "npm run clean:src && npm run clean:test && npm run clean:dist && npm run clean:cover",
|
|
24
25
|
"clean:src": "ts-cleanup -s src --all",
|
|
25
26
|
"clean:test": "ts-cleanup -s test --all",
|
|
@@ -27,10 +28,13 @@
|
|
|
27
28
|
"clean:cover": "rimraf ../../coverage/testing"
|
|
28
29
|
},
|
|
29
30
|
"dependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@opra/
|
|
31
|
+
"@browsery/type-is": "^1.6.18-r3",
|
|
32
|
+
"@opra/client": "^1.0.0-alpha.30",
|
|
33
|
+
"@opra/common": "^1.0.0-alpha.30",
|
|
32
34
|
"ansi-colors": "^4.1.3",
|
|
33
|
-
"
|
|
35
|
+
"jest-matcher-utils": "^29.7.0",
|
|
36
|
+
"rule-judgment": "^1.1.5",
|
|
37
|
+
"tslib": "^2.6.3"
|
|
34
38
|
},
|
|
35
39
|
"type": "module",
|
|
36
40
|
"module": "./esm/index.js",
|
package/types/test-backend.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
3
1
|
import { FetchBackend, HttpResponse } from '@opra/client';
|
|
2
|
+
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
4
3
|
import { ApiExpect } from './api-expect/api-expect.js';
|
|
5
4
|
import type { OpraTestClient } from './test-client.js';
|
|
6
5
|
declare type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|
package/types/test-client.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
3
1
|
import { FetchBackend, HttpClientBase, kBackend } from '@opra/client';
|
|
2
|
+
import { IncomingMessage, Server, ServerResponse } from 'http';
|
|
4
3
|
import { ApiExpect } from './api-expect/api-expect.js';
|
|
5
4
|
import { TestBackend } from './test-backend.js';
|
|
6
5
|
declare type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|