-
Notifications
You must be signed in to change notification settings - Fork 49
chore: migrate from Jest to Vitest and upgrade TypeScript to 5.9 #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { defineConfig } from 'vitest/config'; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| globals: true, | ||
| testTimeout: 30000, | ||
| include: ['test/**/*.test.{ts,tsx,js,mjs}'], | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||
| import { formatXml, parseXml, parseXmlString, serializeXml, writeXml } from './util/xml'; | ||||||
| import { formatXml, parseXml, parseXmlFragment, parseXmlString, serializeXml, writeXml } from './util/xml'; | ||||||
| import xpath, { XPathSelect } from 'xpath'; | ||||||
| import { xml2js, js2xml } from 'xml-js'; | ||||||
| import { VFS, VFSFile, VFSStorable } from './vfs'; | ||||||
|
|
@@ -54,6 +54,19 @@ export class XmlFile extends VFSStorable { | |||||
| return this.doc?.documentElement; | ||||||
| } | ||||||
|
|
||||||
| private getNamespaceAttrs(): string { | ||||||
| const rootNode = this.getDocumentElement(); | ||||||
| if (!rootNode) return ''; | ||||||
| const attrs: string[] = []; | ||||||
| for (const attr in rootNode.attributes) { | ||||||
| const attribute = rootNode.attributes[attr]; | ||||||
| if (attribute.name?.startsWith('xmlns')) { | ||||||
| attrs.push(`${attribute.name}="${attribute.value}"`); | ||||||
| } | ||||||
|
Comment on lines
+61
to
+65
|
||||||
| } | ||||||
| return attrs.join(' '); | ||||||
| } | ||||||
|
|
||||||
| find(target: string): Element[] | null { | ||||||
| if (!this.doc) { | ||||||
| return null; | ||||||
|
|
@@ -99,13 +112,12 @@ export class XmlFile extends VFSStorable { | |||||
| } | ||||||
|
|
||||||
| const nodes = this.select?.(target, this.doc) as Element[]; | ||||||
| const parsed = parseXmlString(fragment); | ||||||
| const docNodes = parsed.childNodes ?? []; | ||||||
| const docNodes = Array.from(parseXmlFragment(fragment, this.getNamespaceAttrs())); | ||||||
|
|
||||||
| Logger.v('xml', 'injectFragment', `at ${target}`); | ||||||
|
|
||||||
| nodes.forEach(n => | ||||||
| Array.prototype.forEach.call(docNodes, d => n.appendChild(d)), | ||||||
| docNodes.forEach(d => n.appendChild(d)), | ||||||
|
||||||
| docNodes.forEach(d => n.appendChild(d)), | |
| docNodes.forEach(d => n.appendChild(d.cloneNode(true))), |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { defineConfig } from 'vitest/config'; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| globals: true, | ||
| testTimeout: 30000, | ||
| include: ['test/**/*.test.{ts,tsx,js,mjs}'], | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This now creates a real temporary directory via
mkdtempSync(...)but nothing cleans it up, so repeated runs can leave manytrapeze-*dirs under the OS temp folder. Consider tracking the created temp directory and removing it when the GradleFile/VFS is finished (or register a process-exit cleanup), or use a temp helper that supports automatic cleanup.