feat(highlightjs): add test

This commit is contained in:
Elian Doran 2025-05-18 11:26:59 +03:00
parent 6625997554
commit 294727600b
No known key found for this signature in database
6 changed files with 74 additions and 3 deletions

View File

@ -5,3 +5,7 @@ This library was generated with [Nx](https://nx.dev).
## Building ## Building
Run `nx build highlightjs` to build the library. Run `nx build highlightjs` to build the library.
## Running unit tests
Run `nx test highlightjs` to execute the unit tests via [Vitest](https://vitest.dev/).

View File

@ -0,0 +1,14 @@
import { describe, it } from "vitest";
import definitions from "./syntax_highlighting.js";
describe("Syntax highlighting definitions", () => {
it("every entry is readable", async () => {
for (const [ mime, mapping ] of Object.entries(definitions)) {
if (mapping === null) {
continue;
}
await mapping.loader;
}
});
});

View File

@ -5,6 +5,9 @@
"references": [ "references": [
{ {
"path": "./tsconfig.lib.json" "path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
} }
] ]
} }

View File

@ -17,5 +17,19 @@
"include": [ "include": [
"src/**/*.ts" "src/**/*.ts"
], ],
"references": [] "references": [],
"exclude": [
"vite.config.ts",
"vite.config.mts",
"vitest.config.ts",
"vitest.config.mts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx"
]
} }

View File

@ -0,0 +1,36 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./out-tsc/vitest",
"types": [
"vitest/globals",
"vitest/importMeta",
"vite/client",
"node",
"vitest"
],
"forceConsistentCasingInFileNames": true,
"noImplicitOverride": true,
"noImplicitReturns": true
},
"include": [
"vite.config.ts",
"vite.config.mts",
"vitest.config.ts",
"vitest.config.mts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
],
"references": [
{
"path": "./tsconfig.lib.json"
}
]
}

View File

@ -1,4 +1,4 @@
/// <reference types='vitest' />
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts'; import dts from 'vite-plugin-dts';
import * as path from 'path'; import * as path from 'path';
@ -6,7 +6,7 @@ import * as path from 'path';
export default defineConfig(() => ({ export default defineConfig(() => ({
root: __dirname, root: __dirname,
cacheDir: '../../node_modules/.vite/packages/highlightjs', cacheDir: '../../node_modules/.vite/packages/highlightjs',
plugins: [dts({ entryRoot: 'src', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json') })], plugins: [dts({ entryRoot: 'src', tsconfigPath: path.join(__dirname, 'tsconfig.lib.json') }), ],
// Uncomment this if you are using workers. // Uncomment this if you are using workers.
// worker: { // worker: {
// plugins: [ nxViteTsPaths() ], // plugins: [ nxViteTsPaths() ],