2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/module/cjs/tests/fixture-cleanup.module.test.cjs
T
Jay 76794ac27a chore: update module test for full check (#7510)
* chore: add additional testing to esm and cjs smoke

* test: updated test suite to include module tests

* fix: esm test smoke import

* fix: cubic feedback

* fix: failing cjs

* fix: cjs timeout
2026-03-15 21:10:52 +02:00

45 lines
1.4 KiB
JavaScript

const assert = require('assert');
const fs = require('fs');
const os = require('os');
const path = require('path');
const { describe, it } = require('mocha');
const { cleanupTempFixture } = require('./helpers/fixture.cjs');
describe('module fixture cleanup helper', () => {
it('removes fixture directories without shelling out to rm', () => {
const fixturePath = fs.mkdtempSync(path.join(os.tmpdir(), 'axios-module-fixture-'));
const nestedPath = path.join(fixturePath, 'nested');
const originalPath = process.env.PATH;
fs.mkdirSync(nestedPath);
fs.writeFileSync(path.join(nestedPath, 'index.ts'), 'export {};\n');
process.env.PATH = '';
try {
cleanupTempFixture(fixturePath);
} finally {
process.env.PATH = originalPath;
}
assert.strictEqual(fs.existsSync(fixturePath), false);
});
it('removes fixture directories when fs.rmSync is unavailable', () => {
const fixturePath = fs.mkdtempSync(path.join(os.tmpdir(), 'axios-module-fixture-legacy-'));
const nestedPath = path.join(fixturePath, 'nested');
const originalRmSync = fs.rmSync;
fs.mkdirSync(nestedPath);
fs.writeFileSync(path.join(nestedPath, 'index.ts'), 'export {};\n');
fs.rmSync = undefined;
try {
cleanupTempFixture(fixturePath);
} finally {
fs.rmSync = originalRmSync;
}
assert.strictEqual(fs.existsSync(fixturePath), false);
});
});