2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/module/esm/tests/ts.module.test.js
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

37 lines
1.1 KiB
JavaScript

import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { describe, it } from 'vitest';
import { createTempFixture, cleanupTempFixture } from './helpers/fixture.js';
import { runCommand } from './helpers/run-command.js';
const suiteRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const repoRoot = path.resolve(suiteRoot, '../../..');
const tscBin = path.join(suiteRoot, 'node_modules', 'typescript', 'bin', 'tsc');
const tsconfig = {
compilerOptions: {
target: 'es2016',
module: 'commonjs',
moduleResolution: 'node',
esModuleInterop: true,
strict: true,
skipLibCheck: true,
},
};
describe('module ts compatibility', () => {
it('compiles and executes import axios syntax', () => {
const sourcePath = path.join(repoRoot, 'test/module/ts/index.ts');
const fixturePath = createTempFixture(suiteRoot, 'ts', sourcePath, tsconfig, {
type: 'commonjs',
});
try {
runCommand('node', [tscBin, '-p', 'tsconfig.json'], { cwd: fixturePath });
runCommand('node', ['index.js'], { cwd: fixturePath });
} finally {
cleanupTempFixture(fixturePath);
}
});
});