@nzz/q-cli 1.8.0 → 1.9.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/bin/commands/bootstrap.js +0 -1
- package/bin/q.js +30 -5
- package/package.json +2 -2
- package/skeletons/et-utils-package-skeleton/README.md +5 -0
- package/skeletons/et-utils-package-skeleton/jest.config.ts +17 -0
- package/skeletons/et-utils-package-skeleton/package.json +19 -13
- package/skeletons/et-utils-package-skeleton/scripts/package-fixup.sh +13 -0
- package/skeletons/et-utils-package-skeleton/test/Service.spec.ts +1 -10
- package/skeletons/et-utils-package-skeleton/test/tsconfig.json +8 -0
- package/skeletons/et-utils-package-skeleton/tsconfig-base.json +10 -0
- package/skeletons/et-utils-package-skeleton/tsconfig-cjs.json +8 -0
- package/skeletons/et-utils-package-skeleton/tsconfig.json +4 -5
- package/skeletons/toolv2-skeleton/.husky/pre-commit +6 -0
- package/skeletons/toolv2-skeleton/.nvmrc +1 -0
- package/skeletons/toolv2-skeleton/.prettierrc.cjs +15 -0
- package/skeletons/toolv2-skeleton/.travis.yml +30 -0
- package/skeletons/toolv2-skeleton/.vscode/settings.json +6 -0
- package/skeletons/toolv2-skeleton/Dockerfile +19 -0
- package/skeletons/toolv2-skeleton/LICENSE +21 -0
- package/skeletons/toolv2-skeleton/README.md +99 -0
- package/skeletons/toolv2-skeleton/dev.js +7 -0
- package/skeletons/toolv2-skeleton/index.js +39 -0
- package/skeletons/toolv2-skeleton/jest.config.ts +39 -0
- package/skeletons/toolv2-skeleton/nodemon.json +4 -0
- package/skeletons/toolv2-skeleton/package-lock.json +21382 -0
- package/skeletons/toolv2-skeleton/package.json +80 -0
- package/skeletons/toolv2-skeleton/resources/display-options-schema.json +11 -0
- package/skeletons/toolv2-skeleton/resources/locales/de/translation.json +8 -0
- package/skeletons/toolv2-skeleton/resources/locales/en/translation.json +10 -0
- package/skeletons/toolv2-skeleton/resources/locales/fr/translation.json +10 -0
- package/skeletons/toolv2-skeleton/resources/schema.json +66 -0
- package/skeletons/toolv2-skeleton/rollup.config.js +48 -0
- package/skeletons/toolv2-skeleton/scripts/postinstall.sh +5 -0
- package/skeletons/toolv2-skeleton/src/.eslintrc.cjs +52 -0
- package/skeletons/toolv2-skeleton/src/components/Main.spec.ts +15 -0
- package/skeletons/toolv2-skeleton/src/components/Main.svelte +32 -0
- package/skeletons/toolv2-skeleton/src/enums.ts +11 -0
- package/skeletons/toolv2-skeleton/src/helpers/fixture-generators.ts +38 -0
- package/skeletons/toolv2-skeleton/src/helpers/toolRuntimeConfig.ts +15 -0
- package/skeletons/toolv2-skeleton/src/interfaces.ts +82 -0
- package/skeletons/toolv2-skeleton/src/modules.d.ts +8 -0
- package/skeletons/toolv2-skeleton/src/routes/dynamic-schemas/exampleDynamicSchema.ts +49 -0
- package/skeletons/toolv2-skeleton/src/routes/dynamic-schemas/index.ts +5 -0
- package/skeletons/toolv2-skeleton/src/routes/health.ts +14 -0
- package/skeletons/toolv2-skeleton/src/routes/locales.ts +31 -0
- package/skeletons/toolv2-skeleton/src/routes/notifications/exampleNotification.ts +46 -0
- package/skeletons/toolv2-skeleton/src/routes/option-availability.ts +27 -0
- package/skeletons/toolv2-skeleton/src/routes/rendering-info/web.ts +150 -0
- package/skeletons/toolv2-skeleton/src/routes/routes.ts +21 -0
- package/skeletons/toolv2-skeleton/src/routes/schema.ts +21 -0
- package/skeletons/toolv2-skeleton/src/routes/stylesheet.ts +31 -0
- package/skeletons/toolv2-skeleton/src/styles/main.scss +6 -0
- package/skeletons/toolv2-skeleton/svelte.config.cjs +6 -0
- package/skeletons/toolv2-skeleton/tasks/compileStyleFiles.cjs +101 -0
- package/skeletons/toolv2-skeleton/tests/e2e-tests.spec.ts +158 -0
- package/skeletons/toolv2-skeleton/tests/helpers.ts +21 -0
- package/skeletons/toolv2-skeleton/tsconfig.json +48 -0
- package/skeletons/et-utils-package-skeleton/rollup.config.js +0 -17
@@ -2,7 +2,6 @@ const fs = require("fs-extra");
|
|
2
2
|
const path = require("path");
|
3
3
|
const replaceInFile = require("replace-in-file");
|
4
4
|
const chalk = require("chalk");
|
5
|
-
const { replace } = require("nunjucks/src/filters");
|
6
5
|
const errorColor = chalk.red;
|
7
6
|
const successColor = chalk.green;
|
8
7
|
const warningColor = chalk.yellow;
|
package/bin/q.js
CHANGED
@@ -47,7 +47,7 @@ async function main() {
|
|
47
47
|
}
|
48
48
|
const baseDir = program.dir || name;
|
49
49
|
const textReplacements = [
|
50
|
-
{ regex: new RegExp(
|
50
|
+
{ regex: new RegExp(`server-skeleton`, "g"), replaceWith: name },
|
51
51
|
];
|
52
52
|
|
53
53
|
await bootstrap("server", baseDir, textReplacements);
|
@@ -61,17 +61,42 @@ async function main() {
|
|
61
61
|
)
|
62
62
|
.description("bootstrap a new tool")
|
63
63
|
.action(async (command) => {
|
64
|
-
|
64
|
+
let name = command.args[0];
|
65
|
+
|
65
66
|
if (!name) {
|
66
67
|
console.error(errorColor("no toolname given"));
|
67
68
|
process.exit(1);
|
68
69
|
}
|
70
|
+
|
71
|
+
// Make sure the name matches the spec.
|
72
|
+
if (!name.match(/^(Q-|q-)\w+/g)) {
|
73
|
+
console.error(errorColor("Tool must be named according to this format: Q-[a-z+]"));
|
74
|
+
process.exit(1);
|
75
|
+
}
|
76
|
+
|
77
|
+
// Capitalize first letter.
|
78
|
+
name = name[0].toUpperCase() + name.substring(1).toLowerCase();
|
79
|
+
|
80
|
+
let nameNodashes = name.replace(/\-/g, '');
|
81
|
+
toolnameCamelCase = nameNodashes[0].toUpperCase() + nameNodashes[1].toUpperCase() + nameNodashes.substring(2);
|
82
|
+
|
69
83
|
const baseDir = program.dir || name;
|
70
84
|
const textReplacements = [
|
71
|
-
|
85
|
+
// deprecated.
|
86
|
+
{ regex: /tool-skeleton/g, replaceWith: name },
|
87
|
+
|
88
|
+
// Replace all instance of tool name with underscore.
|
89
|
+
{ regex: /\[tool_name\]/g, replaceWith: name.toLowerCase().replace(/\-/g, '_') },
|
90
|
+
|
91
|
+
// Replace all instances with minuses.
|
92
|
+
{ regex: /\[Tool-name\]/g, replaceWith: name },
|
93
|
+
{ regex: /\[tool-name\]/g, replaceWith: name.toLowerCase() },
|
94
|
+
|
95
|
+
// Replace all CamelCase instances.
|
96
|
+
{ regex: /\[ToolName\]/g, replaceWith: toolnameCamelCase},
|
72
97
|
];
|
73
98
|
|
74
|
-
await bootstrap("
|
99
|
+
await bootstrap("toolv2", baseDir, textReplacements);
|
75
100
|
});
|
76
101
|
|
77
102
|
program
|
@@ -89,7 +114,7 @@ async function main() {
|
|
89
114
|
}
|
90
115
|
const baseDir = program.dir || name;
|
91
116
|
const textReplacements = [
|
92
|
-
{ regex: new RegExp(
|
117
|
+
{ regex: new RegExp(`custom-code-skeleton`, "g"), replaceWith: name },
|
93
118
|
];
|
94
119
|
|
95
120
|
await bootstrap("custom-code", baseDir, textReplacements);
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nzz/q-cli",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.9.0",
|
4
4
|
"description": "Cli tool to setup new Q tools, new Q server implementations and start Q dev server to test developing Q tools",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -40,4 +40,4 @@
|
|
40
40
|
"promptly": "^3.2.0",
|
41
41
|
"replace-in-file": "^3.4.4"
|
42
42
|
}
|
43
|
-
}
|
43
|
+
}
|
@@ -5,3 +5,8 @@
|
|
5
5
|
## Content
|
6
6
|
|
7
7
|
TODO: Package documentation
|
8
|
+
|
9
|
+
## Modules & Node support
|
10
|
+
|
11
|
+
The package follows a hybrid module structure, supporting ES6 & CommonJS Module imports.
|
12
|
+
Node support can be implemented by changing the internal, relative import statements to include the file type suffix `.js` (not `.ts`!). This however breaks the CommonJS Module imports (`require()`), which should not be an issue if Node 12+ is used in the project.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { Config } from "@jest/types";
|
2
|
+
|
3
|
+
// Sync object
|
4
|
+
const config: Config.InitialOptions = {
|
5
|
+
verbose: true,
|
6
|
+
transform: {
|
7
|
+
"^.+\\.tsx?$": "ts-jest",
|
8
|
+
},
|
9
|
+
};
|
10
|
+
|
11
|
+
config.globals = {
|
12
|
+
"ts-jest": {
|
13
|
+
tsconfig: "<rootDir>/test/tsconfig.json",
|
14
|
+
},
|
15
|
+
};
|
16
|
+
|
17
|
+
export default config;
|
@@ -8,25 +8,31 @@
|
|
8
8
|
"directory": "<package-name>"
|
9
9
|
},
|
10
10
|
"scripts": {
|
11
|
-
"prepublishOnly": "npm run test && npm run clean && npm run
|
12
|
-
"clean": "rimraf dist
|
13
|
-
"
|
14
|
-
"
|
15
|
-
"
|
11
|
+
"prepublishOnly": "npm run test && npm run clean && npm run buildMjs && npm run buildCjs && ./scripts/package-fixup.sh",
|
12
|
+
"clean": "rimraf dist",
|
13
|
+
"buildMjs": "tsc -p tsconfig.json",
|
14
|
+
"buildCjs": "tsc -p tsconfig-cjs.json",
|
15
|
+
"start": "npm run buildMjs -- -w",
|
16
|
+
"test": "jest --config jest.config.ts"
|
17
|
+
},
|
18
|
+
"main": "dist/cjs/index.js",
|
19
|
+
"module": "dist/mjs/index.js",
|
20
|
+
"exports": {
|
21
|
+
".": {
|
22
|
+
"import": "./dist/mjs/index.js",
|
23
|
+
"require": "./dist/cjs/index.js"
|
24
|
+
}
|
16
25
|
},
|
17
|
-
"files": [
|
18
|
-
"index.js",
|
19
|
-
"index.d.ts"
|
20
|
-
],
|
21
26
|
"publishConfig": {
|
22
27
|
"access": "public"
|
23
28
|
},
|
24
29
|
"devDependencies": {
|
25
|
-
"@
|
26
|
-
"@
|
30
|
+
"@types/jest": "^27.5.1",
|
31
|
+
"@types/node": "^16.11.36",
|
32
|
+
"jest": "^28.1.0",
|
27
33
|
"rimraf": "^3.0.2",
|
28
|
-
"
|
29
|
-
"
|
34
|
+
"ts-jest": "^28.0.3",
|
35
|
+
"ts-node": "^10.8.0",
|
30
36
|
"typescript": "^4.6.4"
|
31
37
|
},
|
32
38
|
"author": "<author-name>",
|
@@ -1,19 +1,10 @@
|
|
1
|
-
import * as Lab from "@hapi/lab";
|
2
|
-
import { expect } from "@hapi/code";
|
3
1
|
import { someFunction } from "../src";
|
4
2
|
|
5
|
-
// Hapi Lab init code
|
6
|
-
const lab = Lab.script();
|
7
|
-
const { describe, it, before } = lab;
|
8
|
-
export { lab };
|
9
|
-
|
10
3
|
describe("Service", () => {
|
11
|
-
before(() => {});
|
12
|
-
|
13
4
|
it("should return the konami cheatcode", () => {
|
14
5
|
const result = someFunction();
|
15
6
|
const expectedResult = "Up, Up, Down, Down, Left, Right, Left, Right, B, A";
|
16
7
|
|
17
|
-
expect(result).
|
8
|
+
expect(result).toEqual(expectedResult);
|
18
9
|
});
|
19
10
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
16
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module.exports = {
|
2
|
+
arrowParens: 'avoid',
|
3
|
+
bracketSameLine: true,
|
4
|
+
bracketSpacing: true,
|
5
|
+
plugins: [require('prettier-plugin-svelte')],
|
6
|
+
printWidth: 160,
|
7
|
+
semi: true,
|
8
|
+
singleQuote: true,
|
9
|
+
svelteIndentScriptAndStyle: false,
|
10
|
+
svelteSortOrder: 'options-scripts-markup-styles',
|
11
|
+
svelteStrictMode: false,
|
12
|
+
tabWidth: 2,
|
13
|
+
trailingComma: 'all',
|
14
|
+
useTabs: false,
|
15
|
+
};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
dist: trusty
|
2
|
+
sudo: true
|
3
|
+
services:
|
4
|
+
- docker
|
5
|
+
language: node_js
|
6
|
+
node_js:
|
7
|
+
- '16'
|
8
|
+
cache:
|
9
|
+
directories:
|
10
|
+
- node_modules
|
11
|
+
install:
|
12
|
+
- npm set-script postinstall ""
|
13
|
+
- npm install
|
14
|
+
before_script:
|
15
|
+
- DOCKER_IMAGE_NAME="[tool-name]"
|
16
|
+
- DOCKER_TAG=${TRAVIS_BRANCH//[^a-zA-Z0-9\_\-\.]/_}
|
17
|
+
script:
|
18
|
+
- npm run lint
|
19
|
+
- npm run ts-check
|
20
|
+
- npm run svelte-check
|
21
|
+
- npm run build
|
22
|
+
- npm run jest
|
23
|
+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then docker build -t $DOCKER_IMAGE_NAME:$DOCKER_TAG .; fi'
|
24
|
+
after_success:
|
25
|
+
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then echo $DOCKER_PASSWORD | docker login -u="$DOCKER_USERNAME" --password-stdin; docker tag $DOCKER_IMAGE_NAME:$DOCKER_TAG nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG; docker push nzzonline/$DOCKER_IMAGE_NAME:$DOCKER_TAG; fi'
|
26
|
+
|
27
|
+
# TODO: Create token for slack notifications, then insert below & uncomment lines
|
28
|
+
#notifications:
|
29
|
+
#slack:
|
30
|
+
#secure: <Slack-Token>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Use following version of node alpine as the base image
|
2
|
+
FROM node:16-alpine
|
3
|
+
|
4
|
+
# Set work directory for run/cmd
|
5
|
+
WORKDIR /app
|
6
|
+
|
7
|
+
# Copy package.json and package-lock.json into work directory and install dependencies
|
8
|
+
COPY package.json /app/package.json
|
9
|
+
COPY package-lock.json /app/package-lock.json
|
10
|
+
RUN npm install --production
|
11
|
+
|
12
|
+
# Copy everthing else in work directory
|
13
|
+
COPY . /app
|
14
|
+
|
15
|
+
# Expose server port
|
16
|
+
EXPOSE 3000
|
17
|
+
|
18
|
+
# Run node
|
19
|
+
CMD node index.js
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) NZZ Management AG
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# [tool-name] <travis-badge>
|
2
|
+
|
3
|
+
**maintainer**: <maintainer>
|
4
|
+
|
5
|
+
Short description of tool and link to either [demo](https://editor.q.tools/) or [playground](https://q-playground.st.nzz.ch).
|
6
|
+
|
7
|
+
## Table of contents
|
8
|
+
|
9
|
+
- [Installation](#installation)
|
10
|
+
- [Configuration](#configuration)
|
11
|
+
- [Development](#development)
|
12
|
+
- [Watching files](#watching-files-dev)
|
13
|
+
- [Testing](#testing)
|
14
|
+
- [Deployment](#deployment)
|
15
|
+
- [Functionality](#functionality)
|
16
|
+
- [License](#license)
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
```
|
21
|
+
nvm use
|
22
|
+
npm install
|
23
|
+
npm start
|
24
|
+
```
|
25
|
+
|
26
|
+
[to the top](#table-of-contents)
|
27
|
+
|
28
|
+
## Configuration
|
29
|
+
|
30
|
+
If env variables, explained here
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
Start the Q dev server:
|
35
|
+
|
36
|
+
```
|
37
|
+
npx @nzz/q-cli server
|
38
|
+
```
|
39
|
+
|
40
|
+
Run the Q tool:
|
41
|
+
|
42
|
+
```
|
43
|
+
npm start
|
44
|
+
```
|
45
|
+
|
46
|
+
## Watching files (DEV)
|
47
|
+
|
48
|
+
Please see nodemon.json for a specific list of extension that trigger a rebuilt when changed in development. You can extend this list at your liking.
|
49
|
+
|
50
|
+
[to the top](#table-of-contents)
|
51
|
+
|
52
|
+
## Testing
|
53
|
+
|
54
|
+
Run the tests:
|
55
|
+
|
56
|
+
```
|
57
|
+
npm run test
|
58
|
+
```
|
59
|
+
|
60
|
+
### Implementing a new test
|
61
|
+
|
62
|
+
When changing or implementing...
|
63
|
+
|
64
|
+
- A `route`, it needs to be tested in the `tests/e2e-tests.js` file.
|
65
|
+
- Something on the frontend, it needs to be tested in it's own `***.spec.ts` file.
|
66
|
+
|
67
|
+
[to the top](#table-of-contents)
|
68
|
+
|
69
|
+
## Deployment
|
70
|
+
|
71
|
+
We provide automatically built docker images at https://hub.docker.com/r/nzzonline/[tool-name]/.
|
72
|
+
There are three options for deployment:
|
73
|
+
|
74
|
+
- Use the provided images
|
75
|
+
- Build your own docker images
|
76
|
+
- Deploy the service using another technology
|
77
|
+
|
78
|
+
### Use the provided docker images
|
79
|
+
|
80
|
+
1. Deploy `nzzonline/[tool-name]` to a docker environment
|
81
|
+
2. Set the ENV variables as described in the [configuration section](#configuration)
|
82
|
+
|
83
|
+
[to the top](#table-of-contents)
|
84
|
+
|
85
|
+
## Functionality
|
86
|
+
|
87
|
+
The tool structure follows the general structure of each Q tool. Further information can be found in [Q server documentation - Developing tools](https://nzzdev.github.io/Q-server/developing-tools.html).
|
88
|
+
|
89
|
+
[to the top](#table-of-contents)
|
90
|
+
|
91
|
+
### Options
|
92
|
+
|
93
|
+
All options should be listed and explained. The varieties should be listed. If there's a visual aspect, a printscreen would be nice. The options should be listed as they are named in the `schema`
|
94
|
+
|
95
|
+
[to the top](#table-of-contents)
|
96
|
+
|
97
|
+
## License (if open source)
|
98
|
+
|
99
|
+
Adding the license + updating the year.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import Hapi from '@hapi/hapi';
|
2
|
+
import routes from './dist/routes.js';
|
3
|
+
|
4
|
+
// Because the package is set as module we cannot directly call require
|
5
|
+
// in js files. We must import and create it.
|
6
|
+
import { createRequire } from 'module';
|
7
|
+
const require = createRequire(import.meta.url);
|
8
|
+
|
9
|
+
const server = Hapi.server({
|
10
|
+
port: process.env.PORT || 3000,
|
11
|
+
});
|
12
|
+
|
13
|
+
async function init() {
|
14
|
+
await server.register(require('@hapi/inert'));
|
15
|
+
server.validator(require('joi'));
|
16
|
+
|
17
|
+
server.route(routes);
|
18
|
+
|
19
|
+
await server.start();
|
20
|
+
console.log('server running ', server.info.uri);
|
21
|
+
}
|
22
|
+
|
23
|
+
init();
|
24
|
+
|
25
|
+
async function gracefullyStop() {
|
26
|
+
console.log('stopping hapi server');
|
27
|
+
try {
|
28
|
+
await server.stop({ timeout: 10000 });
|
29
|
+
console.log('hapi server stopped');
|
30
|
+
} catch (err) {
|
31
|
+
console.log(err);
|
32
|
+
process.exit(1);
|
33
|
+
}
|
34
|
+
process.exit(0);
|
35
|
+
}
|
36
|
+
|
37
|
+
// listen on SIGINT and SIGTERM signal and gracefully stop the server.
|
38
|
+
process.on('SIGINT', gracefullyStop);
|
39
|
+
process.on('SIGTERM', gracefullyStop);
|
@@ -0,0 +1,39 @@
|
|
1
|
+
// Testing with Svelte + TS + ESM + Jest requires quite the setup.
|
2
|
+
// https://github.com/svelteness/svelte-jester/issues/72#issuecomment-1021356664
|
3
|
+
|
4
|
+
import type { Config } from '@jest/types';
|
5
|
+
|
6
|
+
const config: Config.InitialOptions = {
|
7
|
+
preset: 'ts-jest/presets/default-esm',
|
8
|
+
testEnvironment: 'jsdom',
|
9
|
+
verbose: true,
|
10
|
+
transform: {
|
11
|
+
'^.+\\.ts$': 'ts-jest',
|
12
|
+
'^.+\\.svelte$': [
|
13
|
+
|
14
|
+
// This line is very important for it to work with ESM modules
|
15
|
+
'./node_modules/svelte-jester/dist/transformer.mjs',
|
16
|
+
{
|
17
|
+
preprocess: true,
|
18
|
+
},
|
19
|
+
],
|
20
|
+
},
|
21
|
+
extensionsToTreatAsEsm: ['.svelte', '.ts'],
|
22
|
+
moduleFileExtensions: ['js', 'ts', 'svelte'],
|
23
|
+
globals: {
|
24
|
+
'ts-jest': {
|
25
|
+
useESM: true,
|
26
|
+
},
|
27
|
+
},
|
28
|
+
moduleNameMapper: {
|
29
|
+
'^(\\.{1,2}/.*)\\.js$': '$1',
|
30
|
+
'^@rs(.*)$': '<rootDir>/resources$1',
|
31
|
+
'^@src(.*)$': '<rootDir>/src$1',
|
32
|
+
},
|
33
|
+
testPathIgnorePatterns: ['node_modules'],
|
34
|
+
transformIgnorePatterns: ['node_modules'],
|
35
|
+
bail: false,
|
36
|
+
setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'],
|
37
|
+
};
|
38
|
+
|
39
|
+
export default config;
|