Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

test(cli): template show and icon pairs keep fixtures in the run folder (#10325)

Christopher Chedeau6b9f734dccca
diff --git a/packages/cli/api/icon/option-pairs.test.mjs b/packages/cli/api/icon/option-pairs.test.mjs
index c489b4cc19..c5f31238de 100644
--- a/packages/cli/api/icon/option-pairs.test.mjs
+++ b/packages/cli/api/icon/option-pairs.test.mjs
@@ -18,6 +18,7 @@ import * as os from 'node:os';
import * as path from 'node:path';
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
import {writeIconSetProject} from '../../test-utils/icon-set-fixture.mjs';
+import {runFolder} from '../../test-utils/global-local-fixtures.mjs';
import {icon} from './icon.mjs';
import {iconAdd} from './add/add.mjs';
import {iconMap} from './map/map.mjs';
@@ -40,10 +41,14 @@ import {doc as useFn} from './iconUse.doc.mjs';
/** @type {string} */
let tmp;
beforeAll(() => {
- tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-icon-pairs-'));
+ // In a run's folder, the node project's global teardown removes every
+ // package the pairs made with the run's other fixtures.
+ tmp = fs.mkdtempSync(
+ path.join(runFolder() ?? os.tmpdir(), 'astryx-icon-pairs-'),
+ );
});
afterAll(() => {
- fs.rmSync(tmp, {recursive: true, force: true});
+ if (!runFolder()) fs.rmSync(tmp, {recursive: true, force: true});
});
const FROM = '@acme/glyph-library';
diff --git a/packages/cli/api/template/show/show.test.mjs b/packages/cli/api/template/show/show.test.mjs
index cb8c9c1e2a..eeb3fbe8ee 100644
--- a/packages/cli/api/template/show/show.test.mjs
+++ b/packages/cli/api/template/show/show.test.mjs
@@ -14,6 +14,7 @@ import * as path from 'node:path';
import {discoverAll, template} from '../template.mjs';
import {templateCopy} from '../copy/copy.mjs';
import {templateShow} from './show.mjs';
+import {runFolder} from '../../../test-utils/global-local-fixtures.mjs';
const SLOW = 60_000;
/** Astryx's demo-media namespace: only its own previews serve these files. */
@@ -28,10 +29,14 @@ describe('template.show', () => {
/** @type {Awaited<ReturnType<typeof discoverAll>>} */
let templates;
beforeAll(async () => {
- dir = fs.mkdtempSync(path.join(os.tmpdir(), 'tmpl-show-'));
+ // In a run's folder, the node project's global teardown removes the
+ // copies of every template with the run's other fixtures.
+ dir = fs.mkdtempSync(path.join(runFolder() ?? os.tmpdir(), 'tmpl-show-'));
templates = await discoverAll(dir);
}, SLOW);
- afterAll(() => fs.rmSync(dir, {recursive: true, force: true}));
+ afterAll(() => {
+ if (!runFolder()) fs.rmSync(dir, {recursive: true, force: true});
+ });
it('returns exactly the source copy writes, for every template', () => {
let withFixtures = 0;