Skip to content

Commit

Permalink
test: do some witchcraft with alias mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
43081j committed Jan 22, 2025
1 parent 8d6ca1c commit 01677bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/parse5/lib/parser/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { it, assert, describe, beforeEach, afterEach, vi, expect } from 'vitest';
import { parseFragment, parse } from 'parse5';
import type { Element, TextNode } from '../tree-adapters/default.js';
import { generateParsingTests } from 'parse5-test-utils/dist/generate-parsing-tests.js';
import { treeAdapters } from 'parse5-test-utils/dist/common.js';
import { generateParsingTests } from 'parse5-test-utils/utils/generate-parsing-tests.js';
import { treeAdapters } from 'parse5-test-utils/utils/common.js';
import type { Htmlparser2TreeAdapterMap } from 'parse5-htmlparser2-tree-adapter';

generateParsingTests(
Expand Down
20 changes: 18 additions & 2 deletions vitest.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
/// <reference types="vitest/config" />
import { defineConfig } from 'vite';
import path from 'node:path';
import { readdirSync } from 'node:fs';

const alias = [
{ find: /^(parse5[^/]*)\/dist\/(.*?)(?:\.js)?$/, replacement: path.resolve('./packages/$1/lib/$2') },
{ find: /^(parse5[^/]*)$/, replacement: path.resolve('./packages/$1/lib/index.ts') },
{ find: /parse5-test-utils\/(.*?)/, replacement: path.resolve('./test/$1') },
];
const packages = readdirSync('./packages');

export default defineConfig({
test: {
include: ['**/*.test.ts'],
workspace: ['packages/*'],
workspace: packages.map((name) => ({
test: {
name,
root: `packages/${name}`,
alias,
},
})),
coverage: {
clean: true,
exclude: ['./packages/*/dist', './scripts', './bench', './*.config.js'],
include: ['packages'],
exclude: ['**/dist/**'],
},
},
});

0 comments on commit 01677bb

Please sign in to comment.