2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/unit/syntaxCompat.test.js
T
Jay 3e6b4e1f31 fix: error unexpected token in fetch JS compatibility issue with Webpack 4 (#10864)
* chore: added npm run lint step between install and build in build-and-run-vitest

* chore: acorn ^8.16.0 added as a devDependency

* test: added test to parse all lib files via acorn

* feat: added globalThis: "readonly"

* feat: ?? replaced with the verbose ternary
2026-05-07 19:36:11 +02:00

31 lines
906 B
JavaScript

import { describe, it, expect } from 'vitest';
import { readFileSync, readdirSync, statSync } from 'node:fs';
import { join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { Parser } from 'acorn';
const LIB_DIR = fileURLToPath(new URL('../../lib/', import.meta.url));
const ECMA_VERSION = 2018;
function walk(dir) {
const out = [];
for (const name of readdirSync(dir)) {
const full = join(dir, name);
if (statSync(full).isDirectory()) out.push(...walk(full));
else if (full.endsWith('.js')) out.push(full);
}
return out;
}
describe('lib/ source files parse as ES2018', () => {
for (const file of walk(LIB_DIR)) {
const rel = file.slice(LIB_DIR.length);
it(rel, () => {
const src = readFileSync(file, 'utf8');
expect(() =>
Parser.parse(src, { ecmaVersion: ECMA_VERSION, sourceType: 'module' })
).not.toThrow();
});
}
});