Wire up tests & sonarcloud
This commit is contained in:
@@ -19,7 +19,8 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "vite build && api-extractor run",
|
"prepare": "vite build && api-extractor run",
|
||||||
"lint:ts": "tsc --noEmit"
|
"lint:ts": "tsc --noEmit",
|
||||||
|
"test": "vitest"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@matrix-org/react-sdk-module-api": "^2.5.0",
|
"@matrix-org/react-sdk-module-api": "^2.5.0",
|
||||||
@@ -27,11 +28,14 @@
|
|||||||
"@types/node": "^22.10.7",
|
"@types/node": "^22.10.7",
|
||||||
"@types/react": "^18",
|
"@types/react": "^18",
|
||||||
"@types/semver": "^7.5.8",
|
"@types/semver": "^7.5.8",
|
||||||
|
"@vitest/coverage-v8": "^3.0.4",
|
||||||
"matrix-web-i18n": "^3.3.0",
|
"matrix-web-i18n": "^3.3.0",
|
||||||
"semver": "^7.6.3",
|
"semver": "^7.6.3",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"vite": "^6.0.11",
|
"vite": "^6.0.11",
|
||||||
"vite-plugin-dts": "^4.5.0"
|
"vite-plugin-dts": "^4.5.0",
|
||||||
|
"vitest": "^3.0.4",
|
||||||
|
"vitest-sonar-reporter": "^2.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@matrix-org/react-sdk-module-api": "*",
|
"@matrix-org/react-sdk-module-api": "*",
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2025 New Vector Ltd.
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
|
Please see LICENSE files in the repository root for full details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { expect, test } from "vitest";
|
||||||
|
|
||||||
|
import { Api, isModule } from "./api.js";
|
||||||
|
|
||||||
|
const TestModule = {
|
||||||
|
default: class TestModule {
|
||||||
|
public static moduleApiVersion = "1.0.0";
|
||||||
|
public constructor(private readonly api: Api) {}
|
||||||
|
public async load(): Promise<void> {
|
||||||
|
console.log("TestModule loaded");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
test("isModule correctly identifies valid modules", () => {
|
||||||
|
expect(isModule(TestModule)).toBe(true);
|
||||||
|
});
|
||||||
@@ -27,4 +27,22 @@ export default defineConfig({
|
|||||||
define: {
|
define: {
|
||||||
__VERSION__: JSON.stringify(process.env.npm_package_version),
|
__VERSION__: JSON.stringify(process.env.npm_package_version),
|
||||||
},
|
},
|
||||||
|
test: {
|
||||||
|
coverage: {
|
||||||
|
provider: "v8",
|
||||||
|
include: ["src/**/*"],
|
||||||
|
reporter: "lcov",
|
||||||
|
},
|
||||||
|
reporters: [
|
||||||
|
[
|
||||||
|
"vitest-sonar-reporter",
|
||||||
|
{
|
||||||
|
outputFile: "coverage/sonar-report.xml",
|
||||||
|
onWritePath(path: string): string {
|
||||||
|
return `packages/element-web-module-api/${path}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user