yerror 6.2.1 → 7.0.0
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/CHANGELOG.md +4 -0
- package/README.md +8 -22
- package/dist/index.d.ts +72 -0
- package/dist/index.js +119 -176
- package/dist/index.js.map +1 -1
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +145 -0
- package/dist/index.test.js.map +1 -0
- package/package.json +89 -71
- package/src/{index.mocha.js → index.test.ts} +74 -55
- package/src/index.ts +192 -0
- package/dist/index.mjs +0 -117
- package/dist/index.mjs.map +0 -1
- package/dist/index.mocha.js +0 -201
- package/dist/index.mocha.js.map +0 -1
- package/dist/index.mocha.mjs +0 -153
- package/dist/index.mocha.mjs.map +0 -1
- package/src/index.d.ts +0 -26
- package/src/index.js +0 -165
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/* eslint max-nested-callbacks:[0], no-magic-numbers:[0] */
|
|
2
|
+
import { describe, test } from '@jest/globals';
|
|
3
|
+
import assert from 'assert';
|
|
4
|
+
import { YError } from './index.js';
|
|
5
|
+
describe('YError', () => {
|
|
6
|
+
describe('.__constructor', () => {
|
|
7
|
+
test('Should work', () => {
|
|
8
|
+
const err = new YError('E_ERROR', 'arg1', 'arg2');
|
|
9
|
+
assert(err instanceof Error);
|
|
10
|
+
assert.equal(err.name, err.toString());
|
|
11
|
+
assert.equal(err.code, 'E_ERROR');
|
|
12
|
+
assert.deepEqual(err.params, ['arg1', 'arg2']);
|
|
13
|
+
assert.equal(err.toString(), 'YError: E_ERROR (arg1, arg2)');
|
|
14
|
+
});
|
|
15
|
+
test('Should work without code', () => {
|
|
16
|
+
const err = new YError();
|
|
17
|
+
assert.equal(err.code, 'E_UNEXPECTED');
|
|
18
|
+
assert.deepEqual(err.params, []);
|
|
19
|
+
assert.equal(err.toString(), 'YError: E_UNEXPECTED ()');
|
|
20
|
+
assert.equal(err.name, err.toString());
|
|
21
|
+
});
|
|
22
|
+
test('Should work without new', () => {
|
|
23
|
+
const err = new YError('E_ERROR', 'arg1', 'arg2');
|
|
24
|
+
assert.equal(err.code, 'E_ERROR');
|
|
25
|
+
assert(err instanceof YError);
|
|
26
|
+
assert.deepEqual(err.params, ['arg1', 'arg2']);
|
|
27
|
+
assert.equal(err.toString(), 'YError: E_ERROR (arg1, arg2)');
|
|
28
|
+
assert.equal(err.name, err.toString());
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('.wrap()', () => {
|
|
32
|
+
test('Should work with standard errors and a message', () => {
|
|
33
|
+
// eslint-disable-line
|
|
34
|
+
const err = YError.wrap(new Error('This is an error!'));
|
|
35
|
+
assert.equal(err.code, 'E_UNEXPECTED');
|
|
36
|
+
assert.equal(err.wrappedErrors.length, 1);
|
|
37
|
+
assert.deepEqual(err.params, ['This is an error!']);
|
|
38
|
+
if ('captureStackTrace' in Error) {
|
|
39
|
+
assert(-1 !== (err.stack || '').indexOf('Error: This is an error!'), 'Stack contains original error.');
|
|
40
|
+
assert(-1 !==
|
|
41
|
+
(err.stack || '').indexOf('YError: E_UNEXPECTED (This is an error!)'), 'Stack contains cast error.');
|
|
42
|
+
assert.equal(err.name, err.toString());
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
test('Should work with standard errors and an error code', () => {
|
|
46
|
+
const err = YError.wrap(new Error('E_ERROR'));
|
|
47
|
+
assert.equal(err.code, 'E_ERROR');
|
|
48
|
+
assert.equal(err.wrappedErrors.length, 1);
|
|
49
|
+
assert.deepEqual(err.params, []);
|
|
50
|
+
if ('captureStackTrace' in Error) {
|
|
51
|
+
assert(-1 !== (err.stack || '').indexOf('Error: E_ERROR'), 'Stack contains original error.');
|
|
52
|
+
assert(-1 !== (err.stack || '').indexOf('YError: E_ERROR ()'), 'Stack contains cast error.');
|
|
53
|
+
}
|
|
54
|
+
assert.equal(err.name, err.toString());
|
|
55
|
+
});
|
|
56
|
+
test('Should work with standard errors, an error code and params', () => {
|
|
57
|
+
const err = YError.wrap(new Error('E_ERROR'), 'E_ERROR_2', 'arg1', 'arg2');
|
|
58
|
+
assert.equal(err.code, 'E_ERROR_2');
|
|
59
|
+
assert.equal(err.wrappedErrors.length, 1);
|
|
60
|
+
assert.deepEqual(err.params, ['arg1', 'arg2']);
|
|
61
|
+
if ('captureStackTrace' in Error) {
|
|
62
|
+
assert(-1 !== (err.stack || '').indexOf('Error: E_ERROR'), 'Stack contains first error.');
|
|
63
|
+
assert(-1 !== (err.stack || '').indexOf('YError: E_ERROR_2 (arg1, arg2)'), 'Stack contains second error.');
|
|
64
|
+
}
|
|
65
|
+
assert.equal(err.name, err.toString());
|
|
66
|
+
});
|
|
67
|
+
test('Should work with several wrapped errors', () => {
|
|
68
|
+
const err = YError.wrap(YError.wrap(new Error('E_ERROR_1'), 'E_ERROR_2', 'arg2.1', 'arg2.2'), 'E_ERROR_3', 'arg3.1', 'arg3.2');
|
|
69
|
+
assert.equal(err.code, 'E_ERROR_3');
|
|
70
|
+
assert.equal(err.wrappedErrors.length, 2);
|
|
71
|
+
assert.deepEqual(err.params, ['arg3.1', 'arg3.2']);
|
|
72
|
+
if ('captureStackTrace' in Error) {
|
|
73
|
+
assert(-1 !== (err.stack || '').indexOf('Error: E_ERROR_1'), 'Stack contains first error.');
|
|
74
|
+
assert(-1 !==
|
|
75
|
+
(err.stack || '').indexOf('YError: E_ERROR_2 (arg2.1, arg2.2)'), 'Stack contains second error.');
|
|
76
|
+
assert(-1 !==
|
|
77
|
+
(err.stack || '').indexOf('YError: E_ERROR_3 (arg3.1, arg3.2)'), 'Stack contains second error.');
|
|
78
|
+
}
|
|
79
|
+
assert.equal(err.name, err.toString());
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe('.cast()', () => {
|
|
83
|
+
test('Should work with standard errors and a message', () => {
|
|
84
|
+
const err = YError.cast(new Error('This is an error!'));
|
|
85
|
+
assert.equal(err.code, 'E_UNEXPECTED');
|
|
86
|
+
assert.equal(err.wrappedErrors.length, 1);
|
|
87
|
+
assert.deepEqual(err.params, ['This is an error!']);
|
|
88
|
+
if ('captureStackTrace' in Error) {
|
|
89
|
+
assert(-1 !== (err.stack || '').indexOf('Error: This is an error!'), 'Stack contains original error.');
|
|
90
|
+
assert(-1 !==
|
|
91
|
+
(err.stack || '').indexOf('YError: E_UNEXPECTED (This is an error!)'), 'Stack contains cast error.');
|
|
92
|
+
}
|
|
93
|
+
assert.equal(err.name, err.toString());
|
|
94
|
+
});
|
|
95
|
+
test('Should let YError instances pass through', () => {
|
|
96
|
+
const err = YError.cast(new YError('E_ERROR', 'arg1', 'arg2'));
|
|
97
|
+
assert.equal(err.code, 'E_ERROR');
|
|
98
|
+
assert.deepEqual(err.params, ['arg1', 'arg2']);
|
|
99
|
+
if ('captureStackTrace' in Error) {
|
|
100
|
+
assert(-1 !== (err.stack || '').indexOf('YError: E_ERROR (arg1, arg2)'), 'Stack contains cast error.');
|
|
101
|
+
}
|
|
102
|
+
assert.equal(err.name, err.toString());
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
describe('.bump()', () => {
|
|
106
|
+
test('Should work with standard errors and a message', () => {
|
|
107
|
+
const err = YError.bump(new Error('This is an error!'));
|
|
108
|
+
assert.equal(err.code, 'E_UNEXPECTED');
|
|
109
|
+
assert.equal(err.wrappedErrors.length, 1);
|
|
110
|
+
assert.deepEqual(err.params, ['This is an error!']);
|
|
111
|
+
if ('captureStackTrace' in Error) {
|
|
112
|
+
assert(-1 !== (err.stack || '').indexOf('Error: This is an error!'), 'Stack contains original error.');
|
|
113
|
+
assert(-1 !==
|
|
114
|
+
(err.stack || '').indexOf('YError: E_UNEXPECTED (This is an error!)'), 'Stack contains bumped error.');
|
|
115
|
+
}
|
|
116
|
+
assert.equal(err.name, err.toString());
|
|
117
|
+
});
|
|
118
|
+
test('Should work with YError like errors', () => {
|
|
119
|
+
const baseErr = new Error('E_A_NEW_ERROR');
|
|
120
|
+
baseErr.code = 'E_A_NEW_ERROR';
|
|
121
|
+
baseErr.params = ['baseParam1', 'baseParam2'];
|
|
122
|
+
const err = YError.bump(baseErr);
|
|
123
|
+
assert.equal(err.code, 'E_A_NEW_ERROR');
|
|
124
|
+
assert.equal(err.wrappedErrors.length, 1);
|
|
125
|
+
assert.deepEqual(err.params, ['baseParam1', 'baseParam2']);
|
|
126
|
+
if ('captureStackTrace' in Error) {
|
|
127
|
+
assert(-1 !== (err.stack || '').indexOf('Error: E_A_NEW_ERROR'), 'Stack contains original error.');
|
|
128
|
+
assert(-1 !==
|
|
129
|
+
(err.stack || '').indexOf('YError: E_A_NEW_ERROR (baseParam1, baseParam2)'), 'Stack contains bumped error.');
|
|
130
|
+
}
|
|
131
|
+
assert.equal(err.name, err.toString());
|
|
132
|
+
});
|
|
133
|
+
test('Should work with Y errors and a message', () => {
|
|
134
|
+
const err = YError.bump(new YError('E_ERROR', 'arg1.1', 'arg1.2'), 'E_ERROR_2', 'arg2.1', 'arg2.2');
|
|
135
|
+
assert.equal(err.code, 'E_ERROR');
|
|
136
|
+
assert.deepEqual(err.params, ['arg1.1', 'arg1.2']);
|
|
137
|
+
if ('captureStackTrace' in Error) {
|
|
138
|
+
assert(-1 !== (err.stack || '').indexOf('YError: E_ERROR (arg1.1, arg1.2)'), 'Stack contains original error.');
|
|
139
|
+
assert(-1 !== (err.stack || '').indexOf('YError: E_ERROR (arg1.1, arg1.2)'), 'Stack contains bumped error.');
|
|
140
|
+
}
|
|
141
|
+
assert.equal(err.name, err.toString());
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,Y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,CAAC;QAEH,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;YACnD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CACrB,IAAI,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC,EACzC,WAAW,EACX,QAAQ,EACR,QAAQ,CACT,CAAC;YAEF,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAClC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;YAEnD,IAAI,mBAAmB,IAAI,KAAK,EAAE;gBAChC,MAAM,CACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,kCAAkC,CAAC,EACpE,gCAAgC,CACjC,CAAC;gBACF,MAAM,CACJ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,kCAAkC,CAAC,EACpE,8BAA8B,CAC/B,CAAC;aACH;YACD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "yerror",
|
|
3
|
-
"version": "6.2.1",
|
|
4
|
-
"description": "It helps to know why you got an error.",
|
|
5
|
-
"main": "dist/index",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "src/index.d.ts",
|
|
8
|
-
"browser": "dist/index",
|
|
9
2
|
"metapak": {
|
|
10
3
|
"configs": [
|
|
11
4
|
"main",
|
|
12
5
|
"readme",
|
|
13
6
|
"eslint",
|
|
14
|
-
"
|
|
7
|
+
"tsesm",
|
|
8
|
+
"jest",
|
|
15
9
|
"codeclimate",
|
|
16
|
-
"
|
|
17
|
-
"travis",
|
|
18
|
-
"karma",
|
|
10
|
+
"ghactions",
|
|
19
11
|
"jsdocs"
|
|
20
12
|
],
|
|
21
13
|
"data": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
14
|
+
"files": "'src/**/*.ts'",
|
|
15
|
+
"testsFiles": "'src/**/*.test.ts'",
|
|
16
|
+
"distFiles": "'dist/**/*.js'",
|
|
24
17
|
"ignore": [
|
|
25
18
|
"dist"
|
|
26
19
|
],
|
|
@@ -30,30 +23,30 @@
|
|
|
30
23
|
]
|
|
31
24
|
}
|
|
32
25
|
},
|
|
26
|
+
"name": "yerror",
|
|
27
|
+
"version": "7.0.0",
|
|
28
|
+
"description": "It helps to know why you got an error.",
|
|
33
29
|
"scripts": {
|
|
34
|
-
"build": "
|
|
30
|
+
"build": "rimraf 'dist' && tsc --outDir dist",
|
|
35
31
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md",
|
|
36
32
|
"cli": "env NODE_ENV=${NODE_ENV:-cli}",
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"compile:mjs": "babel --env-name=mjs --out-file-extension=.mjs --out-dir=dist --source-maps=true src",
|
|
40
|
-
"cover": "nyc npm test && nyc report --reporter=html --reporter=text",
|
|
41
|
-
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls && rm -rf ./coverage",
|
|
33
|
+
"cover": "npm run jest -- --coverage",
|
|
34
|
+
"coveralls": "npm run cover && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage",
|
|
42
35
|
"cz": "env NODE_ENV=${NODE_ENV:-cli} git cz",
|
|
43
|
-
"doc": "echo \"# API\" > API.md; jsdoc2md
|
|
44
|
-
"
|
|
45
|
-
"lint": "eslint src
|
|
36
|
+
"doc": "echo \"# API\" > API.md; jsdoc2md 'dist/**/*.js' >> API.md && git add API.md",
|
|
37
|
+
"jest": "NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest",
|
|
38
|
+
"lint": "eslint 'src/**/*.ts'",
|
|
46
39
|
"metapak": "metapak",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"test": "
|
|
52
|
-
"
|
|
40
|
+
"precz": "npm t && npm run lint && npm run build && npm run metapak -- -s && npm run doc",
|
|
41
|
+
"prettier": "prettier --write 'src/**/*.ts'",
|
|
42
|
+
"preversion": "npm t && npm run lint && npm run build && npm run metapak -- -s && npm run doc",
|
|
43
|
+
"rebuild": "swc ./src -s -d dist -C jsc.target=es2022",
|
|
44
|
+
"test": "echo \"WARNING: No tests specified\" && npm run jest",
|
|
45
|
+
"type-check": "tsc --pretty --noEmit",
|
|
53
46
|
"version": "npm run changelog"
|
|
54
47
|
},
|
|
55
48
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
49
|
+
"node": ">=18.16.0"
|
|
57
50
|
},
|
|
58
51
|
"repository": {
|
|
59
52
|
"type": "git",
|
|
@@ -74,34 +67,26 @@
|
|
|
74
67
|
"url": "https://github.com/nfroidure/yerror/issues"
|
|
75
68
|
},
|
|
76
69
|
"devDependencies": {
|
|
77
|
-
"@
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"babel-plugin-transform-builtin-extend": "^1.1.2",
|
|
86
|
-
"browserify": "^17.0.0",
|
|
87
|
-
"commitizen": "^4.2.4",
|
|
88
|
-
"conventional-changelog-cli": "^2.2.2",
|
|
70
|
+
"@swc/cli": "^0.1.62",
|
|
71
|
+
"@swc/core": "^1.3.76",
|
|
72
|
+
"@swc/helpers": "^0.5.1",
|
|
73
|
+
"@swc/jest": "^0.2.28",
|
|
74
|
+
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
75
|
+
"@typescript-eslint/parser": "^6.3.0",
|
|
76
|
+
"commitizen": "^4.3.0",
|
|
77
|
+
"conventional-changelog-cli": "^3.0.0",
|
|
89
78
|
"coveralls": "^3.1.1",
|
|
90
79
|
"cz-conventional-changelog": "^3.3.0",
|
|
91
|
-
"eslint": "^8.
|
|
92
|
-
"eslint-
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"metapak-nfroidure": "11.2.0",
|
|
102
|
-
"mocha": "^10.0.0",
|
|
103
|
-
"nyc": "^15.1.0",
|
|
104
|
-
"prettier": "^2.6.2"
|
|
80
|
+
"eslint": "^8.46.0",
|
|
81
|
+
"eslint-config-prettier": "^9.0.0",
|
|
82
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
83
|
+
"jest": "^29.6.2",
|
|
84
|
+
"jsdoc-to-markdown": "^8.0.0",
|
|
85
|
+
"metapak": "^5.1.3",
|
|
86
|
+
"metapak-nfroidure": "15.0.0",
|
|
87
|
+
"prettier": "^3.0.1",
|
|
88
|
+
"rimraf": "^5.0.1",
|
|
89
|
+
"typescript": "^5.1.6"
|
|
105
90
|
},
|
|
106
91
|
"dependencies": {},
|
|
107
92
|
"contributors": [],
|
|
@@ -123,31 +108,32 @@
|
|
|
123
108
|
"cz-conventional-changelog",
|
|
124
109
|
"conventional-changelog-cli",
|
|
125
110
|
"eslint",
|
|
126
|
-
"eslint-config-prettier",
|
|
127
111
|
"prettier",
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"@
|
|
131
|
-
"@
|
|
132
|
-
"
|
|
133
|
-
"
|
|
134
|
-
"
|
|
112
|
+
"eslint-config-prettier",
|
|
113
|
+
"eslint-plugin-prettier",
|
|
114
|
+
"@typescript-eslint/eslint-plugin",
|
|
115
|
+
"@typescript-eslint/parser",
|
|
116
|
+
"typescript",
|
|
117
|
+
"rimraf",
|
|
118
|
+
"@swc/cli",
|
|
119
|
+
"@swc/core",
|
|
120
|
+
"@swc/helpers",
|
|
121
|
+
"jest",
|
|
135
122
|
"coveralls",
|
|
136
|
-
"
|
|
137
|
-
"karma",
|
|
138
|
-
"karma-chrome-launcher",
|
|
139
|
-
"karma-firefox-launcher",
|
|
140
|
-
"karma-mocha",
|
|
123
|
+
"@swc/jest",
|
|
141
124
|
"jsdoc-to-markdown"
|
|
142
125
|
]
|
|
143
126
|
},
|
|
144
127
|
"eslintConfig": {
|
|
145
128
|
"extends": [
|
|
146
|
-
"eslint:recommended"
|
|
129
|
+
"eslint:recommended",
|
|
130
|
+
"plugin:prettier/recommended",
|
|
131
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
132
|
+
"plugin:@typescript-eslint/recommended"
|
|
147
133
|
],
|
|
148
134
|
"parserOptions": {
|
|
149
135
|
"ecmaVersion": 2018,
|
|
150
|
-
"sourceType": "
|
|
136
|
+
"sourceType": "script",
|
|
151
137
|
"modules": true
|
|
152
138
|
},
|
|
153
139
|
"env": {
|
|
@@ -161,7 +147,11 @@
|
|
|
161
147
|
],
|
|
162
148
|
"rules": {
|
|
163
149
|
"prettier/prettier": "error"
|
|
164
|
-
}
|
|
150
|
+
},
|
|
151
|
+
"parser": "@typescript-eslint/parser",
|
|
152
|
+
"ignorePatterns": [
|
|
153
|
+
"*.d.ts"
|
|
154
|
+
]
|
|
165
155
|
},
|
|
166
156
|
"prettier": {
|
|
167
157
|
"semi": true,
|
|
@@ -235,5 +225,33 @@
|
|
|
235
225
|
"exclude": [
|
|
236
226
|
"src/*.mocha.js"
|
|
237
227
|
]
|
|
228
|
+
},
|
|
229
|
+
"type": "module",
|
|
230
|
+
"main": "dist/index.js",
|
|
231
|
+
"types": "dist/index.d.ts",
|
|
232
|
+
"jest": {
|
|
233
|
+
"coverageReporters": [
|
|
234
|
+
"lcov"
|
|
235
|
+
],
|
|
236
|
+
"testPathIgnorePatterns": [
|
|
237
|
+
"/node_modules/"
|
|
238
|
+
],
|
|
239
|
+
"roots": [
|
|
240
|
+
"<rootDir>/src"
|
|
241
|
+
],
|
|
242
|
+
"transform": {
|
|
243
|
+
"^.+\\.tsx?$": [
|
|
244
|
+
"@swc/jest",
|
|
245
|
+
{}
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
"testEnvironment": "node",
|
|
249
|
+
"moduleNameMapper": {
|
|
250
|
+
"(.+)\\.js": "$1"
|
|
251
|
+
},
|
|
252
|
+
"extensionsToTreatAsEsm": [
|
|
253
|
+
".ts"
|
|
254
|
+
],
|
|
255
|
+
"prettierPath": null
|
|
238
256
|
}
|
|
239
257
|
}
|