http-snapshotter 0.2.2 → 0.2.3
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
CHANGED
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Take snapshots of HTTP requests for purpose of tests (on node.js).
|
|
4
4
|
|
|
5
|
-
Use-case: Let's say you are testing a server end-point, that makes several external
|
|
5
|
+
Use-case: Let's say you are testing a server end-point, that makes several external HTTP requests for producing a response. In a unit test you would want predictable inputs for any external network calls.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
To have predictable inputs to external requests there are 2 popular approaches:
|
|
8
|
+
1. Mock / Stub the methods that make the network requests with a library like `sinon.js`
|
|
9
|
+
2. Use a mock service.
|
|
10
|
+
|
|
11
|
+
However stubs / fakes take quite a while to write. And a mock service is an additional piece to deploy and maintain.
|
|
12
|
+
|
|
13
|
+
Presenting you another solution:
|
|
14
|
+
3. Create snapshots of the requests automatically the first time you run your test and then replay the snapshot responses on future runs of the test.
|
|
15
|
+
Additionally with the approach, with predictability and speed in mind, one wouldn't want any real network request from being made; and if it does happen, then the test should fail.
|
|
16
|
+
|
|
17
|
+
WARNING: This module isn't concurrent or thread safe yet. You can only use it on serial test runners like `tape`. If you use `ava`, you need to convert tests to run serially with `test.serial()`.
|
|
8
18
|
|
|
9
19
|
Example (test.js):
|
|
10
20
|
|
|
@@ -43,17 +53,17 @@ There is also a `SNAPSHOT=ignore` option to neither read nor write from snapshot
|
|
|
43
53
|
|
|
44
54
|
Tip: When you do `SNAPSHOT=update` to create snapshots, run it against a single test, so you know what exact snapshots that one test created/updated.
|
|
45
55
|
|
|
46
|
-
|
|
56
|
+
Once you are done writing your tests, run your test runner on all your tests and then take a look at `<snapshots directory>/unused-snapshots.log` file to see which snapshot files haven't been used by your final test suite. You can delete unused snapshot files.
|
|
47
57
|
|
|
48
58
|
The tests of this library uses this library itself, check the `tests/` directory and try the tests `npm ci; npm test`.
|
|
49
59
|
|
|
50
60
|
## About snapshot files and its names
|
|
51
61
|
|
|
52
|
-
A snapshot file name uniquely identifies a request. By default it is a combination of HTTP method + URL + body that makes a request unique.
|
|
53
|
-
|
|
62
|
+
A snapshot file name uniquely identifies a request. By default it is a combination of HTTP method + URL + body that makes a request unique (headers are ignored).
|
|
63
|
+
For example, take the filename `get-xkcd-com-info-0-arAlFb5gfcr9aCN.json` - The prefix `get-xkcd-com-info-0` is added just for readability, and the suffix `arAlFb5gfcr9aCN` is a SHA256 hash of concatenated HTTP method + URL + body string that makes the file name unique.
|
|
54
64
|
|
|
55
65
|
However you may want to specially handle some requests. e.g. DynamoDB calls also need the `x-amz-target` header to uniquely identify the request,
|
|
56
|
-
because
|
|
66
|
+
because the header affects the response data. You can add logic to create better snapshot files for this case:
|
|
57
67
|
|
|
58
68
|
```js
|
|
59
69
|
import {
|
|
@@ -72,28 +82,28 @@ async function mySnapshotFilenameGenerator(request) {
|
|
|
72
82
|
return defaultSnapshotFileNameGenerator(request);
|
|
73
83
|
}
|
|
74
84
|
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
85
|
+
// Use a snapshot file name like `dynamodb-get-item-table-name-sezQSulkfiNCk30.json`
|
|
86
|
+
|
|
87
|
+
// Make a more readable file name prefix (.e.g `dynamodb-get-item-table-name`)
|
|
88
|
+
const xAmzHeader = request.headers?.get('x-amz-target')?.split('.').pop() || '';
|
|
89
|
+
const filePrefix = [
|
|
79
90
|
'dynamodb',
|
|
80
91
|
slugify(xAmzHeader),
|
|
81
|
-
slugify(
|
|
92
|
+
slugify((await request.clone().json())?.TableName),
|
|
82
93
|
].filter(Boolean).join('-');
|
|
83
94
|
|
|
84
|
-
//
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}),
|
|
92
|
-
);
|
|
95
|
+
// Make a unique suffix for this request
|
|
96
|
+
const fileSuffixKey = [
|
|
97
|
+
'dynamodb',
|
|
98
|
+
request.url,
|
|
99
|
+
xAmzHeader,
|
|
100
|
+
await request.clone().text(),
|
|
101
|
+
].join('#');
|
|
93
102
|
|
|
94
103
|
return {
|
|
95
104
|
filePrefix,
|
|
96
|
-
|
|
105
|
+
// this key will be hashed with SHA256 to make the final file suffix
|
|
106
|
+
fileSuffixKey,
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
109
|
|
|
@@ -102,9 +112,9 @@ attachSnapshotFilenameGenerator(mySnapshotFilenameGenerator);
|
|
|
102
112
|
|
|
103
113
|
## Same request, varied response
|
|
104
114
|
|
|
105
|
-
There are scenarios where one needs to test varied response for the same call (
|
|
115
|
+
There are scenarios where one needs to test varied response for the same call (e.g GET /account).
|
|
106
116
|
|
|
107
|
-
There are 2 ways to go about this
|
|
117
|
+
There are 2 ways to go about this:
|
|
108
118
|
|
|
109
119
|
Method 1: The easy way it to not touch the existing snapshot file, and use `attachResponseTransformer` to
|
|
110
120
|
change the response on runtime for the specific test:
|
|
@@ -147,11 +157,12 @@ test('Test behavior on a free account', async (t) => {
|
|
|
147
157
|
});
|
|
148
158
|
```
|
|
149
159
|
|
|
150
|
-
Method 2:
|
|
151
|
-
|
|
152
|
-
(building on the last attachSnapshotFilenameGenerator snippet)
|
|
160
|
+
Method 2: By creating a new snapshot file, by adding a unique filename suffix for the specific test you are running.
|
|
161
|
+
And then manually editing the new snapshot file (it is a regular JSON file).
|
|
153
162
|
|
|
163
|
+
(building upon the last attachSnapshotFilenameGenerator snippet)
|
|
154
164
|
```js
|
|
165
|
+
// test2.js
|
|
155
166
|
test('Test behavior on a free account', async (t) => {
|
|
156
167
|
attachSnapshotFilenameGenerator(async (request) => {
|
|
157
168
|
const defaultReturn = mySnapshotFilenameGenerator();
|
|
@@ -170,9 +181,11 @@ test('Test behavior on a free account', async (t) => {
|
|
|
170
181
|
// make fetch() call here
|
|
171
182
|
// assert the test
|
|
172
183
|
|
|
173
|
-
//
|
|
184
|
+
// reset back to old function before moving to next test
|
|
174
185
|
attachSnapshotFilenameGenerator(mySnapshotFilenameGenerator);
|
|
186
|
+
// You could alternatively `import { resetSnapshotFilenameGenerator } from "http-snapshotter"` and call
|
|
187
|
+
// resetSnapshotFilenameGenerator()
|
|
175
188
|
});
|
|
176
189
|
```
|
|
177
190
|
|
|
178
|
-
Now when you run `SNAPHOT=update node
|
|
191
|
+
Now when you run `SNAPHOT=update node test2.js` you will get a snapshot file with `free-account-test-` as prefix. You can now edit the JSON response for this test.
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "http-snapshotter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Snapshot HTTP requests for tests (node.js)",
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"types": "index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
9
|
-
"require": "./index.js"
|
|
9
|
+
"require": "./index.js",
|
|
10
|
+
"types": "./index.d.ts"
|
|
10
11
|
},
|
|
11
12
|
"scripts": {
|
|
12
13
|
"test": "tape tests/**/*.test.* | tap-diff",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const test = require("tape");
|
|
2
|
-
const { resolve } = require("node:path");
|
|
3
|
-
|
|
4
|
-
const { start } = require("../index.js");
|
|
5
|
-
|
|
6
|
-
const snapshotDirectory = resolve(__dirname, "http-snapshots");
|
|
7
|
-
|
|
8
|
-
start({ snapshotDirectory });
|
|
9
|
-
|
|
10
|
-
test("Latest XKCD comic (CJS)", async (t) => {
|
|
11
|
-
const res = await fetch("https://xkcd.com/info.0.json");
|
|
12
|
-
const json = await res.json();
|
|
13
|
-
|
|
14
|
-
t.deepEquals(
|
|
15
|
-
json,
|
|
16
|
-
{
|
|
17
|
-
month: "9",
|
|
18
|
-
num: 2829,
|
|
19
|
-
link: "",
|
|
20
|
-
year: "2023",
|
|
21
|
-
news: "",
|
|
22
|
-
safe_title: "Iceberg Efficiency",
|
|
23
|
-
transcript: "",
|
|
24
|
-
alt: "Our experimental aerogel iceberg with helium pockets manages true 100% efficiency, barely touching the water, and it can even lift off of the surface and fly to more efficiently pursue fleeing hubristic liners.",
|
|
25
|
-
img: "https://imgs.xkcd.com/comics/iceberg_efficiency.png",
|
|
26
|
-
title: "Iceberg Efficiency",
|
|
27
|
-
day: "15",
|
|
28
|
-
},
|
|
29
|
-
"must be deeply equal"
|
|
30
|
-
);
|
|
31
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import test from "tape";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { resolve, dirname } from "node:path";
|
|
4
|
-
import { start } from "../index.mjs";
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = dirname(__filename);
|
|
8
|
-
const snapshotDirectory = resolve(__dirname, "http-snapshots");
|
|
9
|
-
|
|
10
|
-
await start({ snapshotDirectory });
|
|
11
|
-
|
|
12
|
-
test("Latest XKCD comic (ESM)", async (t) => {
|
|
13
|
-
const res = await fetch("https://xkcd.com/info.0.json");
|
|
14
|
-
const json = await res.json();
|
|
15
|
-
|
|
16
|
-
t.deepEquals(
|
|
17
|
-
json,
|
|
18
|
-
{
|
|
19
|
-
month: "9",
|
|
20
|
-
num: 2829,
|
|
21
|
-
link: "",
|
|
22
|
-
year: "2023",
|
|
23
|
-
news: "",
|
|
24
|
-
safe_title: "Iceberg Efficiency",
|
|
25
|
-
transcript: "",
|
|
26
|
-
alt: "Our experimental aerogel iceberg with helium pockets manages true 100% efficiency, barely touching the water, and it can even lift off of the surface and fly to more efficiently pursue fleeing hubristic liners.",
|
|
27
|
-
img: "https://imgs.xkcd.com/comics/iceberg_efficiency.png",
|
|
28
|
-
title: "Iceberg Efficiency",
|
|
29
|
-
day: "15",
|
|
30
|
-
},
|
|
31
|
-
"must be deeply equal"
|
|
32
|
-
);
|
|
33
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"request": {
|
|
3
|
-
"method": "GET",
|
|
4
|
-
"url": "https://xkcd.com/info.0.json",
|
|
5
|
-
"headers": [],
|
|
6
|
-
"body": ""
|
|
7
|
-
},
|
|
8
|
-
"responseType": "json",
|
|
9
|
-
"response": {
|
|
10
|
-
"status": 200,
|
|
11
|
-
"statusText": "OK",
|
|
12
|
-
"headers": [
|
|
13
|
-
[
|
|
14
|
-
"accept-ranges",
|
|
15
|
-
"bytes"
|
|
16
|
-
],
|
|
17
|
-
[
|
|
18
|
-
"age",
|
|
19
|
-
"228"
|
|
20
|
-
],
|
|
21
|
-
[
|
|
22
|
-
"cache-control",
|
|
23
|
-
"max-age=300"
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
"connection",
|
|
27
|
-
"keep-alive"
|
|
28
|
-
],
|
|
29
|
-
[
|
|
30
|
-
"content-encoding",
|
|
31
|
-
"gzip"
|
|
32
|
-
],
|
|
33
|
-
[
|
|
34
|
-
"content-length",
|
|
35
|
-
"287"
|
|
36
|
-
],
|
|
37
|
-
[
|
|
38
|
-
"content-type",
|
|
39
|
-
"application/json"
|
|
40
|
-
],
|
|
41
|
-
[
|
|
42
|
-
"date",
|
|
43
|
-
"Fri, 15 Sep 2023 18:26:59 GMT"
|
|
44
|
-
],
|
|
45
|
-
[
|
|
46
|
-
"etag",
|
|
47
|
-
"W/\"65044c59-1c0\""
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
"expires",
|
|
51
|
-
"Fri, 15 Sep 2023 12:28:00 GMT"
|
|
52
|
-
],
|
|
53
|
-
[
|
|
54
|
-
"last-modified",
|
|
55
|
-
"Fri, 15 Sep 2023 12:21:45 GMT"
|
|
56
|
-
],
|
|
57
|
-
[
|
|
58
|
-
"server",
|
|
59
|
-
"nginx"
|
|
60
|
-
],
|
|
61
|
-
[
|
|
62
|
-
"vary",
|
|
63
|
-
"Accept-Encoding"
|
|
64
|
-
],
|
|
65
|
-
[
|
|
66
|
-
"via",
|
|
67
|
-
"1.1 varnish, 1.1 varnish"
|
|
68
|
-
],
|
|
69
|
-
[
|
|
70
|
-
"x-cache",
|
|
71
|
-
"HIT, HIT"
|
|
72
|
-
],
|
|
73
|
-
[
|
|
74
|
-
"x-cache-hits",
|
|
75
|
-
"4250, 1"
|
|
76
|
-
],
|
|
77
|
-
[
|
|
78
|
-
"x-served-by",
|
|
79
|
-
"cache-dfw-kdal2120106-DFW, cache-dxb1470033-DXB"
|
|
80
|
-
],
|
|
81
|
-
[
|
|
82
|
-
"x-timer",
|
|
83
|
-
"S1694802419.108277,VS0,VE218"
|
|
84
|
-
]
|
|
85
|
-
],
|
|
86
|
-
"body": {
|
|
87
|
-
"month": "9",
|
|
88
|
-
"num": 2829,
|
|
89
|
-
"link": "",
|
|
90
|
-
"year": "2023",
|
|
91
|
-
"news": "",
|
|
92
|
-
"safe_title": "Iceberg Efficiency",
|
|
93
|
-
"transcript": "",
|
|
94
|
-
"alt": "Our experimental aerogel iceberg with helium pockets manages true 100% efficiency, barely touching the water, and it can even lift off of the surface and fly to more efficiently pursue fleeing hubristic liners.",
|
|
95
|
-
"img": "https://imgs.xkcd.com/comics/iceberg_efficiency.png",
|
|
96
|
-
"title": "Iceberg Efficiency",
|
|
97
|
-
"day": "15"
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
"fileSuffixKey": "GET#https://xkcd.com/info.0.json#"
|
|
101
|
-
}
|
package/tsconfig-old.json
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig.json to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Basic Options */
|
|
6
|
-
// "incremental": true, /* Enable incremental compilation */
|
|
7
|
-
"target": "ESNext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
|
-
"module": "nodenext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
// "lib": [], /* Specify library files to be included in the compilation. */
|
|
10
|
-
"allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
|
-
"checkJs": true, /* Report errors in .js files. */
|
|
12
|
-
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
|
13
|
-
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
|
14
|
-
"emitDeclarationOnly": true, /* Generates only a '.d.ts' file. */
|
|
15
|
-
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
|
16
|
-
// "sourceMap": true, /* Generates corresponding '.map' file. */
|
|
17
|
-
// "outFile": "./", /* Concatenate and emit output to single file. */
|
|
18
|
-
// "outDir": "./", /* Redirect output structure to the directory. */
|
|
19
|
-
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
|
|
20
|
-
// "composite": true, /* Enable project compilation */
|
|
21
|
-
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
|
|
22
|
-
// "removeComments": true, /* Do not emit comments to output. */
|
|
23
|
-
// "noEmit": true, /* Do not emit outputs. */
|
|
24
|
-
"noEmitOnError": true, /* Don't generate on error. */
|
|
25
|
-
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
|
|
26
|
-
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
|
|
27
|
-
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
|
28
|
-
|
|
29
|
-
/* Strict Type-Checking Options */
|
|
30
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
31
|
-
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
|
32
|
-
"strictNullChecks": true, /* Enable strict null checks. */
|
|
33
|
-
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
|
34
|
-
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
|
|
35
|
-
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
|
|
36
|
-
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
|
|
37
|
-
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
|
|
38
|
-
|
|
39
|
-
/* Additional Checks */
|
|
40
|
-
"noUnusedLocals": true, /* Report errors on unused locals. */
|
|
41
|
-
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
42
|
-
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
43
|
-
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
44
|
-
|
|
45
|
-
/* Module Resolution Options */
|
|
46
|
-
"moduleResolution": "NodeNext", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
|
47
|
-
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
|
48
|
-
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
|
|
49
|
-
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
|
|
50
|
-
"typeRoots": [
|
|
51
|
-
"./node_modules/@types"
|
|
52
|
-
], /* List of folders to include type definitions from. */
|
|
53
|
-
// "types": [], /* Type declaration files to be included in compilation. */
|
|
54
|
-
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
|
|
55
|
-
"esModuleInterop": false, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
|
|
56
|
-
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
|
|
57
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
58
|
-
|
|
59
|
-
/* Source Map Options */
|
|
60
|
-
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
|
|
61
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
62
|
-
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
|
|
63
|
-
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
|
|
64
|
-
|
|
65
|
-
/* Experimental Options */
|
|
66
|
-
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
|
|
67
|
-
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
|
|
68
|
-
|
|
69
|
-
/* Advanced Options */
|
|
70
|
-
"skipLibCheck": true, /* Skip type checking of declaration files. */
|
|
71
|
-
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
|
|
72
|
-
},
|
|
73
|
-
"include": [
|
|
74
|
-
"src/index.js"
|
|
75
|
-
]
|
|
76
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
-
|
|
27
|
-
/* Modules */
|
|
28
|
-
"module": "NodeNext", /* Specify what module code is generated. */
|
|
29
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
"typeRoots": [
|
|
35
|
-
"./node_modules/@types"
|
|
36
|
-
], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
37
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
38
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
39
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
40
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
41
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
42
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
43
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
44
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
45
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
46
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
47
|
-
|
|
48
|
-
/* JavaScript Support */
|
|
49
|
-
"allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
50
|
-
"checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
51
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
52
|
-
|
|
53
|
-
/* Emit */
|
|
54
|
-
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
55
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
56
|
-
"emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
57
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
58
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
59
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
60
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
61
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
62
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
63
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
64
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
65
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
66
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
67
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
68
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
69
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
70
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
71
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
72
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
73
|
-
"noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
74
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
75
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
76
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
77
|
-
|
|
78
|
-
/* Interop Constraints */
|
|
79
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
80
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
81
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
82
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
83
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
84
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
85
|
-
|
|
86
|
-
/* Type Checking */
|
|
87
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
88
|
-
"noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
89
|
-
"strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
90
|
-
"strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
91
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
92
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
93
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
94
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
95
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
96
|
-
"noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
97
|
-
"noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
98
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
99
|
-
"noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
100
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
101
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
102
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
103
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
104
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
105
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
106
|
-
|
|
107
|
-
/* Completeness */
|
|
108
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
109
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
110
|
-
},
|
|
111
|
-
"include": [
|
|
112
|
-
"index.js"
|
|
113
|
-
]
|
|
114
|
-
}
|