Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .dev/eudiplo/startEudiplo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from "path";
import { GenericContainer, StartedTestContainer, Wait } from "testcontainers";
import { fileURLToPath } from "url";

export async function startEudiplo(): Promise<StartedTestContainer> {
return await new GenericContainer("ghcr.io/openwallet-foundation/eudiplo:6.1.0@sha256:1aa0fd250d40c88f842dd5853dba81f87b75bc435b486b79e0789ed9297440ce")
Expand All @@ -16,7 +16,7 @@ export async function startEudiplo(): Promise<StartedTestContainer> {
.withExposedPorts({ container: 3000, host: 3000 })
.withCopyDirectoriesToContainer([
{
source: path.resolve(path.join(__dirname, "config")),
source: fileURLToPath(new URL("config", import.meta.url)),
target: "/app/assets/config"
}
])
Expand Down
29 changes: 10 additions & 19 deletions packages/app-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"build:notest": "npm run build:node",
"cdep": "tsc && depcruise --config ../../.dependency-cruiser.cjs dist",
"lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
"test": "jest --forceExit",
"test:ci": "jest -i --forceExit --coverage"
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --forceExit",
"test:ci": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i --forceExit --coverage"
},
"jest": {
"collectCoverageFrom": [
Expand All @@ -35,7 +35,9 @@
"lcov"
],
"maxWorkers": 5,
"preset": "ts-jest",
"extensionsToTreatAsEsm": [
".ts"
],
"setupFilesAfterEnv": [
"./test/customMatchers.ts",
"jest-expect-message",
Expand All @@ -44,28 +46,17 @@
"testEnvironment": "node",
"testTimeout": 60000,
"transform": {
"^.+\\.(t|j)s$": [
"^.+\\.ts$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.json"
}
],
"^.+\\.mjs$": [
"babel-jest",
{
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs"
}
]
]
"tsconfig": "test/tsconfig.json",
"useESM": true
}
]
},
"moduleNameMapper": {
"^@verifiables/request-converter$": "<rootDir>/../../node_modules/@verifiables/request-converter/dist/index.js"
"^@verifiables/request-converter$": "<rootDir>/../../node_modules/@verifiables/request-converter/dist/index.js",
"^webcrypto-core$": "<rootDir>/../../node_modules/webcrypto-core/build/webcrypto-core.js"
},
"transformIgnorePatterns": [
"[/\\\\]packages[/\\\\][^/\\\\]+[/\\\\]dist[/\\\\]",
Expand Down
6 changes: 3 additions & 3 deletions packages/app-runtime/test/lib/TestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { IConfigOverwrite } from "@nmshd/transport";
import fs from "fs";
import { defaultsDeep } from "lodash";
import loki from "lokijs";
import path from "path";
import { GenericContainer, Wait } from "testcontainers";
import { fileURLToPath } from "url";
import {
AppConfig,
AppConfigOverwrite,
Expand Down Expand Up @@ -303,7 +303,7 @@ export class TestUtil {

public static async runDeletionJob(): Promise<void> {
const backboneVersion = this.getBackboneVersion();
const appsettingsOverrideLocation = process.env.APPSETTINGS_OVERRIDE_LOCATION ?? `${__dirname}/../../../../.dev/appsettings.override.json`;
const appsettingsOverrideLocation = process.env.APPSETTINGS_OVERRIDE_LOCATION ?? fileURLToPath(new URL("../../../../.dev/appsettings.override.json", import.meta.url));
const backboneNetwork = process.env.BACKBONE_NETWORK ?? "local-test-backbone";

await new GenericContainer(`ghcr.io/nmshd/backbone-identity-deletion-jobs:${backboneVersion}`)
Expand All @@ -317,7 +317,7 @@ export class TestUtil {
private static getBackboneVersion() {
if (process.env.BACKBONE_VERSION) return process.env.BACKBONE_VERSION;

const composeFile = fs.readFileSync(path.resolve(`${__dirname}/../../../../.dev/compose.backbone.yml`));
const composeFile = fs.readFileSync(fileURLToPath(new URL("../../../../.dev/compose.backbone.yml", import.meta.url)));

const regex = /image: ghcr\.io\/nmshd\/backbone-consumer-api:(?<version>[^\r\n]*)@.*/;
const match = composeFile.toString().match(regex);
Expand Down
5 changes: 3 additions & 2 deletions packages/app-runtime/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"compilerOptions": {
"noEmit": true,
"composite": false,
"allowJs": true, // we want to use the ts compiler to compile ESM node modules into CJS which is understood by jest. This is required since those node modules are javascript.
"types": ["jest", "node"]
"module": "ES2022",
"skipLibCheck": true,
"types": ["jest", "node", "lokijs"]
},
"files": ["../../../node_modules/jest-expect-message/types/index.d.ts"],
"include": ["**/*.ts", "../src/**/*.ts"],
Expand Down
35 changes: 13 additions & 22 deletions packages/consumption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"cdep": "tsc && depcruise --config ../../.dependency-cruiser.cjs dist",
"lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
"test:ci": "npm run test",
"test:ci:lokijs": "USE_LOKIJS=true jest -i --coverage",
"test:ci:mongodb": "jest -i",
"test:local:ferretdb": "npm run test:local:start:ferretdb && CONNECTION_STRING='mongodb://root:example@localhost:27022' jest",
"test:local:lokijs": "USE_LOKIJS=true jest",
"test:local:mongodb": "npm run test:local:start:mongodb && CONNECTION_STRING='mongodb://root:example@localhost:27021' jest",
"test:ci:lokijs": "USE_LOKIJS=true NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i --coverage",
"test:ci:mongodb": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i",
"test:local:ferretdb": "npm run test:local:start:ferretdb && CONNECTION_STRING='mongodb://root:example@localhost:27022' NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:local:lokijs": "USE_LOKIJS=true NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:local:mongodb": "npm run test:local:start:mongodb && CONNECTION_STRING='mongodb://root:example@localhost:27021' NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:local:start:ferretdb": "docker compose -f ../../.dev/compose.yml up -d runtime-ferret",
"test:local:start:mongodb": "docker compose -f ../../.dev/compose.yml up -d runtime-mongo",
"test:local:teardown": "docker compose -f ../../.dev/compose.yml rm -fsv"
Expand All @@ -42,7 +42,9 @@
"lcov"
],
"maxWorkers": 1,
"preset": "ts-jest",
"extensionsToTreatAsEsm": [
".ts"
],
"setupFilesAfterEnv": [
"./test/customMatchers.ts",
"jest-expect-message",
Expand All @@ -51,28 +53,17 @@
"testEnvironment": "node",
"testTimeout": 60000,
"transform": {
"^.+\\.(t|j)s$": [
"^.+\\.ts$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.json"
}
],
"^.+\\.mjs$": [
"babel-jest",
{
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs"
}
]
]
"tsconfig": "test/tsconfig.json",
"useESM": true
}
]
},
"moduleNameMapper": {
"^@verifiables/request-converter$": "<rootDir>/../../node_modules/@verifiables/request-converter/dist/index.js"
"^@verifiables/request-converter$": "<rootDir>/../../node_modules/@verifiables/request-converter/dist/index.js",
"^webcrypto-core$": "<rootDir>/../../node_modules/webcrypto-core/build/webcrypto-core.js"
},
"transformIgnorePatterns": [
"[/\\\\]packages[/\\\\][^/\\\\]+[/\\\\]dist[/\\\\]",
Expand Down
5 changes: 3 additions & 2 deletions packages/consumption/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"compilerOptions": {
"noEmit": true,
"composite": false,
"allowJs": true, // we want to use the ts compiler to compile ESM node modules into CJS which is understood by jest. This is required since those node modules are javascript.
"types": ["jest", "node"]
"module": "ES2022",
"skipLibCheck": true,
"types": ["jest", "node", "lokijs"]
},
"files": ["../../../node_modules/jest-expect-message/types/index.d.ts"],
"include": ["**/*.ts", "../src/**/*.ts"],
Expand Down
11 changes: 7 additions & 4 deletions packages/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"build:notest": "npm run build:node",
"cdep": "tsc && depcruise --config ../../.dependency-cruiser.cjs dist",
"lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
"test": "jest",
"test:ci": "jest -i --coverage"
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:ci": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i --coverage"
},
"jest": {
"collectCoverageFrom": [
Expand All @@ -35,7 +35,9 @@
"lcov"
],
"maxWorkers": 5,
"preset": "ts-jest",
"extensionsToTreatAsEsm": [
".ts"
],
"setupFilesAfterEnv": [
"jest-expect-message",
"../../jest.setup.cjs"
Expand All @@ -46,7 +48,8 @@
"^.+\\.ts$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.json"
"tsconfig": "test/tsconfig.json",
"useESM": true
}
]
}
Expand Down
1 change: 1 addition & 0 deletions packages/content/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"noEmit": true,
"composite": false,
"module": "ES2022",
"types": ["jest", "node"]
},
"files": ["../../../node_modules/jest-expect-message/types/index.d.ts"],
Expand Down
11 changes: 7 additions & 4 deletions packages/core-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"build:ci": "tsc",
"cdep": "tsc && depcruise --config ../../.dependency-cruiser.cjs dist",
"lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
"test": "jest -i",
"test:ci": "jest -i --coverage"
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i",
"test:ci": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i --coverage"
},
"jest": {
"collectCoverageFrom": [
Expand All @@ -33,7 +33,9 @@
"lcov"
],
"maxWorkers": 1,
"preset": "ts-jest",
"extensionsToTreatAsEsm": [
".ts"
],
"setupFilesAfterEnv": [
"jest-expect-message",
"../../jest.setup.cjs"
Expand All @@ -44,7 +46,8 @@
"^.+\\.ts$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.json"
"tsconfig": "test/tsconfig.json",
"useESM": true
}
]
}
Expand Down
1 change: 1 addition & 0 deletions packages/core-types/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"noEmit": true,
"composite": false,
"module": "ES2022",
"types": ["jest", "node"]
},
"files": ["../../../node_modules/jest-expect-message/types/index.d.ts"],
Expand Down
35 changes: 13 additions & 22 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"build:schemas": "node scripts/buildSchemas.mjs",
"cdep": "tsc && depcruise --config ../../.dependency-cruiser.cjs dist",
"lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
"test:ci:lokijs": "USE_LOKIJS=true jest -i --coverage",
"test:ci:mongodb": "jest -i --coverage",
"test:local:ferretdb": "npm run test:local:start:ferretdb && CONNECTION_STRING='mongodb://root:example@localhost:27022' jest",
"test:local:lokijs": "USE_LOKIJS=true jest",
"test:local:mongodb": "npm run test:local:start:mongodb && CONNECTION_STRING='mongodb://root:example@localhost:27021' jest",
"test:ci:lokijs": "USE_LOKIJS=true NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i --coverage",
"test:ci:mongodb": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest -i --coverage",
"test:local:ferretdb": "npm run test:local:start:ferretdb && CONNECTION_STRING='mongodb://root:example@localhost:27022' NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:local:lokijs": "USE_LOKIJS=true NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:local:mongodb": "npm run test:local:start:mongodb && CONNECTION_STRING='mongodb://root:example@localhost:27021' NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest",
"test:local:start:ferretdb": "docker compose -f ../../.dev/compose.yml up -d runtime-ferret",
"test:local:start:mongodb": "docker compose -f ../../.dev/compose.yml up -d runtime-mongo",
"test:local:teardown": "docker compose -f ../../.dev/compose.yml rm -fsv"
Expand All @@ -42,7 +42,9 @@
"lcov"
],
"maxWorkers": 1,
"preset": "ts-jest",
"extensionsToTreatAsEsm": [
".ts"
],
"setupFilesAfterEnv": [
"./test/customMatchers.ts",
"./test/disableTimeoutForDebugging.ts",
Expand All @@ -52,28 +54,17 @@
"testEnvironment": "node",
"testTimeout": 60000,
"transform": {
"^.+\\.(t|j)s$": [
"^.+\\.ts$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.json"
}
],
"^.+\\.mjs$": [
"babel-jest",
{
"presets": [
[
"@babel/preset-env",
{
"modules": "commonjs"
}
]
]
"tsconfig": "test/tsconfig.json",
"useESM": true
}
]
},
"moduleNameMapper": {
"^@verifiables/request-converter$": "<rootDir>/../../node_modules/@verifiables/request-converter/dist/index.js"
"^@verifiables/request-converter$": "<rootDir>/../../node_modules/@verifiables/request-converter/dist/index.js",
"^webcrypto-core$": "<rootDir>/../../node_modules/webcrypto-core/build/webcrypto-core.js"
},
"transformIgnorePatterns": [
"[/\\\\]packages[/\\\\][^/\\\\]+[/\\\\]dist[/\\\\]",
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime/test/disableTimeoutForDebugging.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { jest } from "@jest/globals";

/* Disable timeout errors if we're debugging */
if (process.env.NODE_OPTIONS !== undefined && process.env.NODE_OPTIONS.search("inspect") !== -1) {
jest.setTimeout(1e9);
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/test/lib/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { IdentityUtil, SynchronizedCollection } from "@nmshd/transport";
import fs from "fs";
import _ from "lodash";
import { DateTime } from "luxon";
import { fileURLToPath } from "url";
import {
AttributeSucceededEvent,
ConsumptionServices,
Expand Down Expand Up @@ -204,7 +205,7 @@ export async function makeUploadRequest(values: object = {}): Promise<UploadOwnF
return {
title: "aTitle",
filename: "aFileName",
content: await fs.promises.readFile(`${__dirname}/../__assets__/test.txt`),
content: await fs.promises.readFile(fileURLToPath(new URL("../__assets__/test.txt", import.meta.url))),
mimetype: "aMimetype",
description: "aDescription",
expiresAt: DateTime.utc().plus({ minutes: 5 }).toString(),
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime/test/transport/files.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CoreDate } from "@nmshd/core-types";
import fs from "fs";
import { DateTime } from "luxon";
import { fileURLToPath } from "url";
import { GetFilesQuery, OwnerRestriction, TransportServices } from "../../src";
import { cleanupFiles, exchangeFile, makeUploadRequest, QueryParamConditions, RuntimeServiceProvider, TestRuntimeServices, uploadFile } from "../lib";

Expand Down Expand Up @@ -97,7 +98,7 @@ describe("File upload", () => {
});

test("can upload same file twice", async () => {
const request = await makeUploadRequest({ content: await fs.promises.readFile(`${__dirname}/../__assets__/test.txt`) });
const request = await makeUploadRequest({ content: await fs.promises.readFile(fileURLToPath(new URL("../__assets__/test.txt", import.meta.url))) });

const response1 = await transportServices1.files.uploadOwnFile(request);
const response2 = await transportServices1.files.uploadOwnFile(request);
Expand Down Expand Up @@ -203,7 +204,7 @@ describe("Get file", () => {

describe("Upload big files", () => {
test("can not upload a file that is bigger than 10MB", async () => {
const file = await fs.promises.readFile(`${__dirname}/../__assets__/upload-10+mb.bin`);
const file = await fs.promises.readFile(fileURLToPath(new URL("../__assets__/upload-10+mb.bin", import.meta.url)));

const response = await transportServices1.files.uploadOwnFile(await makeUploadRequest({ content: file }));
expect(response).toBeAnError("'content' is too large", "error.runtime.validation.invalidPropertyValue");
Expand Down
5 changes: 3 additions & 2 deletions packages/runtime/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"compilerOptions": {
"noEmit": true,
"composite": false,
"allowJs": true, // we want to use the ts compiler to compile ESM node modules into CJS which is understood by jest. This is required since those node modules are javascript.
"types": ["jest", "node"]
"module": "ES2022",
"skipLibCheck": true,
"types": ["jest", "node", "lokijs"]
},
"files": ["../../../node_modules/jest-expect-message/types/index.d.ts"],
"include": ["**/*.ts", "../src/**/*.ts"],
Expand Down
Loading