@jaypie/testkit 1.0.0 → 1.0.2
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/README.md +13 -0
- package/package.json +1 -1
- package/src/index.js +2 -0
- package/src/mockLog.module.js +3 -0
- package/.eslintrc.cjs +0 -40
- package/.github/workflows/npm-deploy.yml +0 -55
- package/.vscode/settings.json +0 -24
- package/_templates/jaypie/hygen/jest.command.ejs.t +0 -14
- package/_templates/jaypie/hygen/new.ejs.t +0 -31
- package/_templates/jaypie/hygen/prompt.cjs +0 -37
- package/_templates/jaypie/hygen/prompt.ejs.t +0 -44
- package/_templates/jaypie/hygen/test.ejs.t +0 -52
- package/_templates/jaypie/vite/new.ejs.t +0 -28
- package/_templates/jaypie/vite/prompt.cjs +0 -35
- package/_templates/jaypie/vite/test.ejs.t +0 -49
- package/_templates/jaypie/vite/vitest.command.ejs.t +0 -11
- package/_templates/jaypie/vitest/jest.command.ejs.t +0 -11
- package/_templates/jaypie/vitest/prompt.cjs +0 -41
- package/_templates/jaypie/vitest/test.ejs.t +0 -49
- package/_templates/jaypie/workflow-npm/npm-deploy.ejs.t +0 -58
- package/_templates/jaypie/workflow-npm/prompt.cjs +0 -32
- package/src/__tests__/index.spec.js +0 -29
- package/src/__tests__/jsonApiSchema.module.spec.js +0 -17
- package/src/__tests__/matchers.module.spec.js +0 -39
- package/src/__tests__/mockLog.module.spec.js +0 -95
- package/src/matchers/__tests__/toBeJaypieError.matcher.spec.js +0 -100
- package/testSetup.js +0 -3
- package/vite.config.js +0 -10
package/README.md
CHANGED
|
@@ -86,6 +86,7 @@ expect(json).toBeJaypieError();
|
|
|
86
86
|
|
|
87
87
|
```
|
|
88
88
|
import {
|
|
89
|
+
LOG,
|
|
89
90
|
jsonApiErrorSchema,
|
|
90
91
|
jsonApiSchema,
|
|
91
92
|
matchers,
|
|
@@ -95,6 +96,17 @@ import {
|
|
|
95
96
|
} from '@jaypie/testkit'
|
|
96
97
|
```
|
|
97
98
|
|
|
99
|
+
### `LOG`
|
|
100
|
+
|
|
101
|
+
`LOG` constant provided by `@jaypie/core` for convenience
|
|
102
|
+
|
|
103
|
+
```javascript
|
|
104
|
+
import { log } from "@jaypie/core";
|
|
105
|
+
import { LOG } from "@jaypie/testkit";
|
|
106
|
+
|
|
107
|
+
const libLogger = log.lib({ level: LOG.LEVEL.WARN, lib: "myLib" });
|
|
108
|
+
```
|
|
109
|
+
|
|
98
110
|
### `jsonApiErrorSchema`
|
|
99
111
|
|
|
100
112
|
A [JSON Schema](https://json-schema.org/) validator for the [JSON:API](https://jsonapi.org/) error schema. Powers the `toBeJaypieError` matcher (via `toMatchSchema`).
|
|
@@ -216,6 +228,7 @@ test("log", () => {
|
|
|
216
228
|
|
|
217
229
|
| Date | Version | Summary |
|
|
218
230
|
| ---------- | ------- | -------------- |
|
|
231
|
+
| 3/20/2024 | 1.0.2 | Export `LOG` |
|
|
219
232
|
| 3/16/2024 | 1.0.0 | Artists ship |
|
|
220
233
|
| 3/15/2024 | 0.1.0 | Initial deploy |
|
|
221
234
|
| 3/15/2024 | 0.0.1 | Initial commit |
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// Export
|
|
4
4
|
//
|
|
5
5
|
|
|
6
|
+
export { LOG } from "@jaypie/core";
|
|
7
|
+
|
|
6
8
|
export { jsonApiErrorSchema, jsonApiSchema } from "./jsonApiSchema.module.js";
|
|
7
9
|
export { default as matchers } from "./matchers.module.js";
|
|
8
10
|
export { mockLogFactory, restoreLog, spyLog } from "./mockLog.module.js";
|
package/src/mockLog.module.js
CHANGED
|
@@ -7,6 +7,7 @@ export function mockLogFactory() {
|
|
|
7
7
|
error: vi.fn(),
|
|
8
8
|
fatal: vi.fn(),
|
|
9
9
|
info: vi.fn(),
|
|
10
|
+
lib: vi.fn(),
|
|
10
11
|
tag: vi.fn(),
|
|
11
12
|
trace: vi.fn(),
|
|
12
13
|
untag: vi.fn(),
|
|
@@ -22,6 +23,7 @@ export function mockLogFactory() {
|
|
|
22
23
|
mock.trace.var = mock.var;
|
|
23
24
|
mock.warn.var = mock.var;
|
|
24
25
|
// Have modules return correct objects
|
|
26
|
+
mock.lib.mockReturnValue(mock);
|
|
25
27
|
mock.with.mockReturnValue(mock);
|
|
26
28
|
|
|
27
29
|
// Create something in the shape of the module
|
|
@@ -30,6 +32,7 @@ export function mockLogFactory() {
|
|
|
30
32
|
error: mock.error,
|
|
31
33
|
fatal: mock.fatal,
|
|
32
34
|
info: mock.info,
|
|
35
|
+
lib: mock.lib,
|
|
33
36
|
tag: mock.tag,
|
|
34
37
|
trace: mock.trace,
|
|
35
38
|
untag: mock.untag,
|
package/.eslintrc.cjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
es6: true,
|
|
5
|
-
node: true,
|
|
6
|
-
},
|
|
7
|
-
extends: [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:import/errors",
|
|
10
|
-
// "Add plugin:prettier/recommended as the last item in the extends array in your .eslintrc* config file, so that eslint-config-prettier has the opportunity to override other configs"
|
|
11
|
-
"plugin:prettier/recommended",
|
|
12
|
-
],
|
|
13
|
-
overrides: [
|
|
14
|
-
{
|
|
15
|
-
files: ["__tests__/**", "**/*.spec.js", "**/*.test.js"],
|
|
16
|
-
plugins: ["vitest"],
|
|
17
|
-
extends: ["plugin:vitest/recommended"],
|
|
18
|
-
rules: {
|
|
19
|
-
"vitest/no-focused-tests": "error",
|
|
20
|
-
"vitest/no-disabled-tests": "warn",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
files: ["*.cjs"],
|
|
25
|
-
rules: {
|
|
26
|
-
"import/no-commonjs": "off",
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
parserOptions: {
|
|
31
|
-
ecmaVersion: "latest",
|
|
32
|
-
sourceType: "module",
|
|
33
|
-
},
|
|
34
|
-
plugins: ["prettier"],
|
|
35
|
-
rules: {
|
|
36
|
-
"import/extensions": ["error", "ignorePackages"],
|
|
37
|
-
"import/no-commonjs": "error",
|
|
38
|
-
"no-console": "warn",
|
|
39
|
-
},
|
|
40
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
name: NPM Deploy
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
tags:
|
|
6
|
-
- v*
|
|
7
|
-
|
|
8
|
-
env:
|
|
9
|
-
PROJECT_ENV: meta
|
|
10
|
-
PROJECT_SERVICE: libraries
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
deploy:
|
|
14
|
-
name: NPM Deploy
|
|
15
|
-
permissions:
|
|
16
|
-
id-token: write # for aws-actions/configure-aws-credentials
|
|
17
|
-
contents: read # for actions/checkout
|
|
18
|
-
runs-on: ubuntu-latest
|
|
19
|
-
steps:
|
|
20
|
-
- name: Checkout Code
|
|
21
|
-
uses: actions/checkout@v4
|
|
22
|
-
- name: NPM Install (`npm install`)
|
|
23
|
-
run: npm install
|
|
24
|
-
- name: NPM Deploy
|
|
25
|
-
run: |
|
|
26
|
-
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
|
27
|
-
npm publish --access public
|
|
28
|
-
lint:
|
|
29
|
-
name: Lint (in parallel)
|
|
30
|
-
runs-on: ubuntu-latest
|
|
31
|
-
steps:
|
|
32
|
-
- name: Checkout code
|
|
33
|
-
uses: actions/checkout@v4
|
|
34
|
-
- name: Install dependencies
|
|
35
|
-
run: npm ci
|
|
36
|
-
- name: Run ESLint
|
|
37
|
-
run: npm run lint
|
|
38
|
-
# run: npx eslint . --max-warnings=0
|
|
39
|
-
test:
|
|
40
|
-
name: Unit Test (in parallel)
|
|
41
|
-
runs-on: ubuntu-latest
|
|
42
|
-
strategy:
|
|
43
|
-
matrix:
|
|
44
|
-
node-version: [18.x, 20.x]
|
|
45
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
46
|
-
steps:
|
|
47
|
-
- uses: actions/checkout@v4
|
|
48
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
49
|
-
uses: actions/setup-node@v4
|
|
50
|
-
with:
|
|
51
|
-
node-version: ${{ matrix.node-version }}
|
|
52
|
-
cache: 'npm'
|
|
53
|
-
- run: npm ci
|
|
54
|
-
- run: |
|
|
55
|
-
npm test
|
package/.vscode/settings.json
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"cSpell.words": [
|
|
3
|
-
"certificatemanager",
|
|
4
|
-
"clonedeep",
|
|
5
|
-
"composables",
|
|
6
|
-
"Finlayson",
|
|
7
|
-
"fontface",
|
|
8
|
-
"hygen",
|
|
9
|
-
"iconsets",
|
|
10
|
-
"initzero",
|
|
11
|
-
"jaypie",
|
|
12
|
-
"knowdev",
|
|
13
|
-
"oidc",
|
|
14
|
-
"pinia",
|
|
15
|
-
"roboto",
|
|
16
|
-
"sorpresa",
|
|
17
|
-
"testkit",
|
|
18
|
-
"unplugin",
|
|
19
|
-
"vendia",
|
|
20
|
-
"vuekit",
|
|
21
|
-
"vuetify",
|
|
22
|
-
"wght"
|
|
23
|
-
]
|
|
24
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= hygen %>/<%= generator %>/<%= action %>/jest.command.ejs.t
|
|
3
|
-
---
|
|
4
|
-
---
|
|
5
|
-
inject: true
|
|
6
|
-
to: package.json
|
|
7
|
-
after: scripts
|
|
8
|
-
skip_if: spec<%- '<' %>%= colonSubspec %<%- '>' %>.+<%- '<' %>%= path %<%- '>' %>/__tests__/<%- '<' %>%= name %<%- '>' %><%- '<' %>%= dotSubtype %<%- '>' %>.spec.js
|
|
9
|
-
sh: |
|
|
10
|
-
if jq -e '.scripts["format:package"]' package.json <%- '>' %> /dev/null; then
|
|
11
|
-
npm run format:package 2<%- '>' %> /dev/null || true
|
|
12
|
-
fi
|
|
13
|
-
---
|
|
14
|
-
"test:spec<%- '<' %>%= colonSubspec %<%- '>' %>:<%- '<' %>%= name %<%- '>' %><%- '<' %>%= dotSubtype %<%- '>' %>": "vitest run ./<%- '<' %>%= path %<%- '>' %>/__tests__/<%- '<' %>%= name %<%- '>' %><%- '<' %>%= dotSubtype %<%- '>' %>.spec.js",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= hygen %>/<%= generator %>/<%= action %>/new.ejs.t
|
|
3
|
-
---
|
|
4
|
-
---
|
|
5
|
-
to: <%- '<' %>%= path %<%- '>' %>/<%- '<' %>%= name %<%- '>' %><%- '<' %>%= dotSubtype %<%- '>' %>.js
|
|
6
|
-
---
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// Constants
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// Helper Functions
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// Main
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
const <%- '<' %>%= name %<%- '>' %> = () =<%- '>' %> {
|
|
23
|
-
//
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
// Export
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
export default <%- '<' %>%= name %<%- '>' %>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// see types of prompts:
|
|
2
|
-
// https://github.com/enquirer/enquirer/tree/master/examples
|
|
3
|
-
//
|
|
4
|
-
module.exports = [
|
|
5
|
-
{
|
|
6
|
-
type: "input",
|
|
7
|
-
name: "actionInput",
|
|
8
|
-
message: "Action name (e.g., 'file'):",
|
|
9
|
-
onSubmit: (name, value, input) => {
|
|
10
|
-
// Remove leading './' and trailing '/'
|
|
11
|
-
value = value.replace(/^\.?\/|\/$/g, "");
|
|
12
|
-
input.state.answers.action = value;
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
type: "input",
|
|
17
|
-
name: "generatorInput",
|
|
18
|
-
initial: "project",
|
|
19
|
-
message: "Hygen generator directory (e.g., 'jaypie'):",
|
|
20
|
-
onSubmit: (name, value, input) => {
|
|
21
|
-
// Remove leading './' and trailing '/'
|
|
22
|
-
value = value.replace(/^\.?\/|\/$/g, "");
|
|
23
|
-
input.state.answers.generator = value;
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
type: "input",
|
|
28
|
-
name: "hygenInput",
|
|
29
|
-
initial: "_templates",
|
|
30
|
-
message: "Hygen template directory (always '_templates'):",
|
|
31
|
-
onSubmit: (name, value, input) => {
|
|
32
|
-
// Remove leading './' and trailing '/'
|
|
33
|
-
value = value.replace(/^\.?\/|\/$/g, "");
|
|
34
|
-
input.state.answers.hygen = value;
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
];
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= hygen %>/<%= generator %>/<%= action %>/prompt.cjs
|
|
3
|
-
---
|
|
4
|
-
// see types of prompts:
|
|
5
|
-
// https://github.com/enquirer/enquirer/tree/master/examples
|
|
6
|
-
//
|
|
7
|
-
module.exports = [
|
|
8
|
-
{
|
|
9
|
-
type: "input",
|
|
10
|
-
name: "pathInput",
|
|
11
|
-
initial: "src/util",
|
|
12
|
-
message: "Path (e.g., 'cdk/lib'):",
|
|
13
|
-
onSubmit: (name, value, input) =<%- '>' %> {
|
|
14
|
-
input.state.answers.path = value;
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
type: "input",
|
|
19
|
-
name: "nameInput",
|
|
20
|
-
message: "File name (e.g., 'sum'):",
|
|
21
|
-
onSubmit: (name, value, input) =<%- '>' %> {
|
|
22
|
-
input.state.answers.name = value;
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: "input",
|
|
27
|
-
name: "subtypeInput",
|
|
28
|
-
message: "Subtype (optional; e.g., 'function'):",
|
|
29
|
-
onSubmit: (name, value, input) =<%- '>' %> {
|
|
30
|
-
input.state.answers.subtype = value;
|
|
31
|
-
input.state.answers.dotSubtype = value ? `.${value}` : "";
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: "input",
|
|
36
|
-
name: "subspecInput",
|
|
37
|
-
message:
|
|
38
|
-
"Sub-spec test, for `npm run test:spec:SUBSPEC:sum.function` command (e.g., 'express' or 'lib:project'):",
|
|
39
|
-
onSubmit: (name, value, input) =<%- '>' %> {
|
|
40
|
-
input.state.answers.subspec = value;
|
|
41
|
-
input.state.answers.colonSubspec = value ? `:${value}` : "";
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
];
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= hygen %>/<%= generator %>/<%= action %>/test.ejs.t
|
|
3
|
-
---
|
|
4
|
-
---
|
|
5
|
-
to: <%- '<' %>%= path %<%- '>' %>/__tests__/<%- '<' %>%= name %<%- '>' %><%- '<' %>%= dotSubtype %<%- '>' %>.spec.js
|
|
6
|
-
---
|
|
7
|
-
// eslint-disable-next-line no-unused-vars
|
|
8
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
9
|
-
|
|
10
|
-
// Subject
|
|
11
|
-
import <%- '<' %>%= name %<%- '>' %> from "../<%- '<' %>%= name %<%- '>' %><%- '<' %>%= dotSubtype %<%- '>' %>.js";
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// Mock constants
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// Mock modules
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// Mock environment
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
const DEFAULT_ENV = process.env;
|
|
29
|
-
beforeEach(() =<%- '>' %> {
|
|
30
|
-
process.env = { ...process.env };
|
|
31
|
-
});
|
|
32
|
-
afterEach(() =<%- '>' %> {
|
|
33
|
-
process.env = DEFAULT_ENV;
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
// Run tests
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
<%- '<' %>%_
|
|
42
|
-
let Subtype = "";
|
|
43
|
-
// If subtype is defined, capitalize the first letter
|
|
44
|
-
if(subtype) Subtype = " " + subtype.charAt(0).toUpperCase() + subtype.slice(1);
|
|
45
|
-
_%<%- '>' %>
|
|
46
|
-
describe("<%- '<' %>%= Name %<%- '>' %><%- '<' %>%= Subtype %<%- '>' %>", () =<%- '>' %> {
|
|
47
|
-
it("Works", () =<%- '>' %> {
|
|
48
|
-
const response = <%- '<' %>%= name %<%- '>' %>();
|
|
49
|
-
console.log("response :<%- '>' %><%- '>' %> ", response);
|
|
50
|
-
expect(response).not.toBeUndefined();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= path %>/<%= name %><%= dotSubtype %>.js
|
|
3
|
-
---
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// Constants
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// Helper Functions
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// Main
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
const <%= name %> = () => {
|
|
20
|
-
//
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
// Export
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
export default <%= name %>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// see types of prompts:
|
|
2
|
-
// https://github.com/enquirer/enquirer/tree/master/examples
|
|
3
|
-
//
|
|
4
|
-
module.exports = [
|
|
5
|
-
{
|
|
6
|
-
type: "input",
|
|
7
|
-
name: "path",
|
|
8
|
-
initial: "src",
|
|
9
|
-
message: "Path (e.g., 'src/util' no leading './' or trailing '/'):",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
type: "input",
|
|
13
|
-
name: "name",
|
|
14
|
-
message: "File name (e.g., 'sum' not 'sum.function'):",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
type: "input",
|
|
18
|
-
name: "subtype",
|
|
19
|
-
message: "Subtype (optional; e.g., 'function'):",
|
|
20
|
-
onSubmit: (name, value, input) => {
|
|
21
|
-
// eslint-disable-next-line no-param-reassign
|
|
22
|
-
input.state.answers.dotSubtype = value ? `.${value}` : "";
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
type: "input",
|
|
27
|
-
name: "subspec",
|
|
28
|
-
message:
|
|
29
|
-
"Sub-spec test, for `npm run test:spec:SUBSPEC:sum.function` command (e.g., 'express'):",
|
|
30
|
-
onSubmit: (name, value, input) => {
|
|
31
|
-
// eslint-disable-next-line no-param-reassign
|
|
32
|
-
input.state.answers.colonSubspec = value ? `:${value}` : "";
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
];
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= path %>/__tests__/<%= name %><%= dotSubtype %>.spec.js
|
|
3
|
-
---
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
|
|
7
|
-
// Subject
|
|
8
|
-
import <%= name %> from "../<%= name %><%= dotSubtype %>.js";
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// Mock constants
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// Mock modules
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// Mock environment
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
const DEFAULT_ENV = process.env;
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
process.env = { ...process.env };
|
|
28
|
-
});
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
process.env = DEFAULT_ENV;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// Run tests
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
<%_
|
|
39
|
-
let Subtype = "";
|
|
40
|
-
// If subtype is defined, capitalize the first letter
|
|
41
|
-
if(subtype) Subtype = " " + subtype.charAt(0).toUpperCase() + subtype.slice(1);
|
|
42
|
-
_%>
|
|
43
|
-
describe("<%= Name %><%= Subtype %>", () => {
|
|
44
|
-
it("Works", () => {
|
|
45
|
-
const response = <%= name %>();
|
|
46
|
-
console.log("response :>> ", response);
|
|
47
|
-
expect(response).not.toBeUndefined();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
inject: true
|
|
3
|
-
to: package.json
|
|
4
|
-
after: scripts
|
|
5
|
-
skip_if: spec<%= colonSubspec %>.+<%= path %>/__tests__/<%= name %><%= dotSubtype %>.spec.js
|
|
6
|
-
sh: |
|
|
7
|
-
if jq -e '.scripts["format:package"]' package.json > /dev/null; then
|
|
8
|
-
npm run format:package 2> /dev/null || true
|
|
9
|
-
fi
|
|
10
|
-
---
|
|
11
|
-
"test:spec<%= colonSubspec %>:<%= name %><%= dotSubtype %>": "vitest run ./<%= path %>/__tests__/<%= name %><%= dotSubtype %>.spec.js",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
inject: true
|
|
3
|
-
to: package.json
|
|
4
|
-
after: scripts
|
|
5
|
-
skip_if: spec<%= colonSubspec %>.+<%= path %>/__tests__/<%= name %><%= dotSubtype %>.spec.js
|
|
6
|
-
sh: |
|
|
7
|
-
if jq -e '.scripts["format:package"]' package.json > /dev/null; then
|
|
8
|
-
npm run format:package 2> /dev/null || true
|
|
9
|
-
fi
|
|
10
|
-
---
|
|
11
|
-
"test:spec<%= colonSubspec %>:<%= name %><%= dotSubtype %>": "vitest run ./<%= path %>/__tests__/<%= name %><%= dotSubtype %>.spec.js",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// see types of prompts:
|
|
2
|
-
// https://github.com/enquirer/enquirer/tree/master/examples
|
|
3
|
-
//
|
|
4
|
-
module.exports = [
|
|
5
|
-
{
|
|
6
|
-
type: "input",
|
|
7
|
-
name: "pathInput",
|
|
8
|
-
initial: "src",
|
|
9
|
-
message: "Path (e.g., 'src/util'):",
|
|
10
|
-
onSubmit: (name, value, input) => {
|
|
11
|
-
input.state.answers.path = value;
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: "input",
|
|
16
|
-
name: "nameInput",
|
|
17
|
-
message: "File name (e.g., 'sum'):",
|
|
18
|
-
onSubmit: (name, value, input) => {
|
|
19
|
-
input.state.answers.name = value;
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
type: "input",
|
|
24
|
-
name: "subtypeInput",
|
|
25
|
-
message: "Subtype (optional; e.g., 'function'):",
|
|
26
|
-
onSubmit: (name, value, input) => {
|
|
27
|
-
input.state.answers.subtype = value;
|
|
28
|
-
input.state.answers.dotSubtype = value ? `.${value}` : "";
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: "input",
|
|
33
|
-
name: "subspecInput",
|
|
34
|
-
message:
|
|
35
|
-
"Sub-spec test, for `npm run test:spec:SUBSPEC:sum.function` command (e.g., 'express' or 'lib:project'):",
|
|
36
|
-
onSubmit: (name, value, input) => {
|
|
37
|
-
input.state.answers.subspec = value;
|
|
38
|
-
input.state.answers.colonSubspec = value ? `:${value}` : "";
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
];
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= path %>/__tests__/<%= name %><%= dotSubtype %>.spec.js
|
|
3
|
-
---
|
|
4
|
-
// eslint-disable-next-line no-unused-vars
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
-
|
|
7
|
-
// Subject
|
|
8
|
-
import <%= name %> from "../<%= name %><%= dotSubtype %>.js";
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
// Mock constants
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// Mock modules
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
// Mock environment
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
const DEFAULT_ENV = process.env;
|
|
26
|
-
beforeEach(() => {
|
|
27
|
-
process.env = { ...process.env };
|
|
28
|
-
});
|
|
29
|
-
afterEach(() => {
|
|
30
|
-
process.env = DEFAULT_ENV;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
// Run tests
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
<%_
|
|
39
|
-
let Subtype = "";
|
|
40
|
-
// If subtype is defined, capitalize the first letter
|
|
41
|
-
if(subtype) Subtype = " " + subtype.charAt(0).toUpperCase() + subtype.slice(1);
|
|
42
|
-
_%>
|
|
43
|
-
describe("<%= Name %><%= Subtype %>", () => {
|
|
44
|
-
it("Works", () => {
|
|
45
|
-
const response = <%= name %>();
|
|
46
|
-
console.log("response :>> ", response);
|
|
47
|
-
expect(response).not.toBeUndefined();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
to: <%= path %>/<%= name %>.yml
|
|
3
|
-
---
|
|
4
|
-
name: NPM Deploy
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
tags:
|
|
9
|
-
- v*
|
|
10
|
-
|
|
11
|
-
env:
|
|
12
|
-
PROJECT_ENV: meta
|
|
13
|
-
PROJECT_SERVICE: libraries
|
|
14
|
-
|
|
15
|
-
jobs:
|
|
16
|
-
deploy:
|
|
17
|
-
name: NPM Deploy
|
|
18
|
-
permissions:
|
|
19
|
-
id-token: write # for aws-actions/configure-aws-credentials
|
|
20
|
-
contents: read # for actions/checkout
|
|
21
|
-
runs-on: ubuntu-latest
|
|
22
|
-
steps:
|
|
23
|
-
- name: Checkout Code
|
|
24
|
-
uses: actions/checkout@v4
|
|
25
|
-
- name: NPM Install (`npm install`)
|
|
26
|
-
run: npm install
|
|
27
|
-
- name: NPM Deploy
|
|
28
|
-
run: |
|
|
29
|
-
npm config set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
|
|
30
|
-
npm publish --access <%= access %>
|
|
31
|
-
lint:
|
|
32
|
-
name: Lint (in parallel)
|
|
33
|
-
runs-on: ubuntu-latest
|
|
34
|
-
steps:
|
|
35
|
-
- name: Checkout code
|
|
36
|
-
uses: actions/checkout@v4
|
|
37
|
-
- name: Install dependencies
|
|
38
|
-
run: npm ci
|
|
39
|
-
- name: Run ESLint
|
|
40
|
-
run: npm run lint
|
|
41
|
-
# run: npx eslint . --max-warnings=0
|
|
42
|
-
test:
|
|
43
|
-
name: Unit Test (in parallel)
|
|
44
|
-
runs-on: ubuntu-latest
|
|
45
|
-
strategy:
|
|
46
|
-
matrix:
|
|
47
|
-
node-version: [18.x, 20.x]
|
|
48
|
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
49
|
-
steps:
|
|
50
|
-
- uses: actions/checkout@v4
|
|
51
|
-
- name: Use Node.js ${{ matrix.node-version }}
|
|
52
|
-
uses: actions/setup-node@v4
|
|
53
|
-
with:
|
|
54
|
-
node-version: ${{ matrix.node-version }}
|
|
55
|
-
cache: 'npm'
|
|
56
|
-
- run: npm ci
|
|
57
|
-
- run: |
|
|
58
|
-
npm test
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// see types of prompts:
|
|
2
|
-
// https://github.com/enquirer/enquirer/tree/master/examples
|
|
3
|
-
//
|
|
4
|
-
module.exports = [
|
|
5
|
-
{
|
|
6
|
-
type: "input",
|
|
7
|
-
name: "accessInput",
|
|
8
|
-
initial: "public",
|
|
9
|
-
message: "Access ('public' or 'restricted'):",
|
|
10
|
-
onSubmit: (name, value, input) => {
|
|
11
|
-
input.state.answers.access = value;
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
type: "input",
|
|
16
|
-
name: "pathInput",
|
|
17
|
-
initial: ".github/workflows",
|
|
18
|
-
message: "Path (always '.github/workflows'):",
|
|
19
|
-
onSubmit: (name, value, input) => {
|
|
20
|
-
input.state.answers.path = value;
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
type: "input",
|
|
25
|
-
name: "nameInput",
|
|
26
|
-
initial: "npm-deploy",
|
|
27
|
-
message: "File name, no extension (always 'npm-deploy'):",
|
|
28
|
-
onSubmit: (name, value, input) => {
|
|
29
|
-
input.state.answers.name = value;
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
];
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
// Subject
|
|
4
|
-
import {
|
|
5
|
-
jsonApiErrorSchema,
|
|
6
|
-
jsonApiSchema,
|
|
7
|
-
matchers,
|
|
8
|
-
mockLogFactory,
|
|
9
|
-
restoreLog,
|
|
10
|
-
spyLog,
|
|
11
|
-
} from "../index.js";
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
// Run tests
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
describe("Index", () => {
|
|
19
|
-
it("Exports functions", () => {
|
|
20
|
-
expect(mockLogFactory).toBeFunction();
|
|
21
|
-
expect(restoreLog).toBeFunction();
|
|
22
|
-
expect(spyLog).toBeFunction();
|
|
23
|
-
});
|
|
24
|
-
it("Exports matchers", () => {
|
|
25
|
-
expect(jsonApiErrorSchema).toBeObject();
|
|
26
|
-
expect(jsonApiSchema).toBeObject();
|
|
27
|
-
expect(matchers).toBeObject();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
// Subject
|
|
5
|
-
import { jsonApiErrorSchema, jsonApiSchema } from "../jsonApiSchema.module.js";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// Run tests
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
describe("Json Api Schema Module", () => {
|
|
13
|
-
it("Exports objects", () => {
|
|
14
|
-
expect(jsonApiSchema).toBeObject();
|
|
15
|
-
expect(jsonApiErrorSchema).toBeObject();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
// Subject
|
|
5
|
-
import matchers from "../matchers.module.js";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// Mock constants
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
// Mock modules
|
|
15
|
-
//
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
// Mock environment
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
const DEFAULT_ENV = process.env;
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
process.env = { ...process.env };
|
|
25
|
-
});
|
|
26
|
-
afterEach(() => {
|
|
27
|
-
process.env = DEFAULT_ENV;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// Run tests
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
describe("Matchers Module", () => {
|
|
36
|
-
it("Is an object", () => {
|
|
37
|
-
expect(matchers).toBeObject();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
-
|
|
3
|
-
// Subject
|
|
4
|
-
import { mockLogFactory, restoreLog, spyLog } from "../mockLog.module.js";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
// Mock environment
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
afterEach(() => {
|
|
12
|
-
vi.clearAllMocks();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
// Run tests
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
describe("Mock Log Function", () => {
|
|
21
|
-
it("Exports functions", () => {
|
|
22
|
-
expect(mockLogFactory).toBeFunction();
|
|
23
|
-
expect(restoreLog).toBeFunction();
|
|
24
|
-
expect(spyLog).toBeFunction();
|
|
25
|
-
});
|
|
26
|
-
describe("Features", () => {
|
|
27
|
-
it("mockLogFactory produces a Jaypie logger", () => {
|
|
28
|
-
const log = mockLogFactory();
|
|
29
|
-
expect(log).toBeObject();
|
|
30
|
-
expect(log.debug).toBeFunction();
|
|
31
|
-
expect(log.error).toBeFunction();
|
|
32
|
-
expect(log.fatal).toBeFunction();
|
|
33
|
-
expect(log.info).toBeFunction();
|
|
34
|
-
expect(log.tag).toBeFunction();
|
|
35
|
-
expect(log.trace).toBeFunction();
|
|
36
|
-
expect(log.untag).toBeFunction();
|
|
37
|
-
expect(log.var).toBeFunction();
|
|
38
|
-
expect(log.warn).toBeFunction();
|
|
39
|
-
expect(log.with).toBeFunction();
|
|
40
|
-
});
|
|
41
|
-
it("spyLog swaps out log functions", () => {
|
|
42
|
-
const log = mockLogFactory();
|
|
43
|
-
const original = { ...log };
|
|
44
|
-
spyLog(log);
|
|
45
|
-
expect(log).toBeObject();
|
|
46
|
-
expect(log.debug).toBeFunction();
|
|
47
|
-
expect(log.error).toBeFunction();
|
|
48
|
-
expect(log.fatal).toBeFunction();
|
|
49
|
-
expect(log.info).toBeFunction();
|
|
50
|
-
expect(log.tag).toBeFunction();
|
|
51
|
-
expect(log.trace).toBeFunction();
|
|
52
|
-
expect(log.untag).toBeFunction();
|
|
53
|
-
expect(log.var).toBeFunction();
|
|
54
|
-
expect(log.warn).toBeFunction();
|
|
55
|
-
expect(log.with).toBeFunction();
|
|
56
|
-
expect(log.debug).not.toEqual(original.debug);
|
|
57
|
-
expect(log.error).not.toEqual(original.error);
|
|
58
|
-
expect(log.fatal).not.toEqual(original.fatal);
|
|
59
|
-
expect(log.info).not.toEqual(original.info);
|
|
60
|
-
expect(log.tag).not.toEqual(original.tag);
|
|
61
|
-
expect(log.trace).not.toEqual(original.trace);
|
|
62
|
-
expect(log.untag).not.toEqual(original.untag);
|
|
63
|
-
expect(log.var).not.toEqual(original.var);
|
|
64
|
-
expect(log.warn).not.toEqual(original.warn);
|
|
65
|
-
expect(log.with).not.toEqual(original.with);
|
|
66
|
-
});
|
|
67
|
-
it("restoreLog swaps back original log functions", () => {
|
|
68
|
-
const log = mockLogFactory();
|
|
69
|
-
const original = { ...log };
|
|
70
|
-
spyLog(log);
|
|
71
|
-
restoreLog(log);
|
|
72
|
-
expect(log).toBeObject();
|
|
73
|
-
expect(log.debug).toBeFunction();
|
|
74
|
-
expect(log.error).toBeFunction();
|
|
75
|
-
expect(log.fatal).toBeFunction();
|
|
76
|
-
expect(log.info).toBeFunction();
|
|
77
|
-
expect(log.tag).toBeFunction();
|
|
78
|
-
expect(log.trace).toBeFunction();
|
|
79
|
-
expect(log.untag).toBeFunction();
|
|
80
|
-
expect(log.var).toBeFunction();
|
|
81
|
-
expect(log.warn).toBeFunction();
|
|
82
|
-
expect(log.with).toBeFunction();
|
|
83
|
-
expect(log.debug).toEqual(original.debug);
|
|
84
|
-
expect(log.error).toEqual(original.error);
|
|
85
|
-
expect(log.fatal).toEqual(original.fatal);
|
|
86
|
-
expect(log.info).toEqual(original.info);
|
|
87
|
-
expect(log.tag).toEqual(original.tag);
|
|
88
|
-
expect(log.trace).toEqual(original.trace);
|
|
89
|
-
expect(log.untag).toEqual(original.untag);
|
|
90
|
-
expect(log.var).toEqual(original.var);
|
|
91
|
-
expect(log.warn).toEqual(original.warn);
|
|
92
|
-
expect(log.with).toEqual(original.with);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line no-unused-vars
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
-
|
|
4
|
-
import { ConfigurationError } from "@jaypie/core";
|
|
5
|
-
|
|
6
|
-
// Subject
|
|
7
|
-
import toBeJaypieError from "../toBeJaypieError.matcher.js";
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// Mock constants
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
// Mock modules
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// Mock environment
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
const DEFAULT_ENV = process.env;
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
process.env = { ...process.env };
|
|
27
|
-
});
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
process.env = DEFAULT_ENV;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
// Run tests
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
describe("To Be Jaypie Error Matcher", () => {
|
|
38
|
-
it("Is a function", () => {
|
|
39
|
-
expect(toBeJaypieError).toBeFunction();
|
|
40
|
-
});
|
|
41
|
-
describe("Error Conditions", () => {
|
|
42
|
-
it("Rejects instances of plain error objects", () => {
|
|
43
|
-
const error = new Error(
|
|
44
|
-
"If this is your first night at Fight Club, you have to fight",
|
|
45
|
-
);
|
|
46
|
-
const result = toBeJaypieError(error);
|
|
47
|
-
expect(result.message).toBeFunction();
|
|
48
|
-
expect(result.message()).toBeString();
|
|
49
|
-
expect(result.pass).toBeFalse();
|
|
50
|
-
});
|
|
51
|
-
it("Rejects if nothing passed", () => {
|
|
52
|
-
const result = toBeJaypieError();
|
|
53
|
-
expect(result.message).toBeFunction();
|
|
54
|
-
expect(result.message()).toBeString();
|
|
55
|
-
expect(result.pass).toBeFalse();
|
|
56
|
-
});
|
|
57
|
-
it("Rejects if non-object passed", () => {
|
|
58
|
-
const result = toBeJaypieError(12);
|
|
59
|
-
expect(result.message).toBeFunction();
|
|
60
|
-
expect(result.message()).toBeString();
|
|
61
|
-
expect(result.pass).toBeFalse();
|
|
62
|
-
});
|
|
63
|
-
it("Rejects if no errors array", () => {
|
|
64
|
-
const result = toBeJaypieError({});
|
|
65
|
-
expect(result.message).toBeFunction();
|
|
66
|
-
expect(result.message()).toBeString();
|
|
67
|
-
expect(result.pass).toBeFalse();
|
|
68
|
-
});
|
|
69
|
-
it("Rejects if errors array is empty", () => {
|
|
70
|
-
const result = toBeJaypieError({ errors: [] });
|
|
71
|
-
expect(result.message).toBeFunction();
|
|
72
|
-
expect(result.message()).toBeString();
|
|
73
|
-
expect(result.pass).toBeFalse();
|
|
74
|
-
});
|
|
75
|
-
it("Must match the entire json:api error schema", () => {
|
|
76
|
-
const result = toBeJaypieError({ errors: ["taco"] });
|
|
77
|
-
expect(result.message).toBeFunction();
|
|
78
|
-
expect(result.message()).toBeString();
|
|
79
|
-
expect(result.pass).toBeFalse();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
describe("Happy Path", () => {
|
|
83
|
-
it("Matches instances of Jaypie error objects", () => {
|
|
84
|
-
const error = new ConfigurationError();
|
|
85
|
-
const result = toBeJaypieError(error);
|
|
86
|
-
expect(result.message).toBeFunction();
|
|
87
|
-
expect(result.message()).toBeString();
|
|
88
|
-
expect(result.pass).toBeTrue();
|
|
89
|
-
});
|
|
90
|
-
it("Matches plain old json errors", () => {
|
|
91
|
-
const error = new ConfigurationError(
|
|
92
|
-
"If this is your first night at Fight Club, you have to fight",
|
|
93
|
-
).json();
|
|
94
|
-
const result = toBeJaypieError(error);
|
|
95
|
-
expect(result.message).toBeFunction();
|
|
96
|
-
expect(result.message()).toBeString();
|
|
97
|
-
expect(result.pass).toBeTrue();
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
package/testSetup.js
DELETED