react-native-builder-bob
Version:
CLI to build JavaScript files for React Native libraries
26 lines • 1.04 kB
JavaScript
import fs from 'node:fs';
import path from 'node:path';
import { expect, test } from 'vitest';
import { transformFileAsync } from '@babel/core';
import plugin from "../babel.js";
test.each(['imports', 'exports'])(`adds extension to %s`, async (name) => {
const filepath = path.resolve(import.meta.dirname, `../__fixtures__/project/code/$${name}-input.ts`);
const result = await transformFileAsync(filepath, {
caller: {
name: 'test',
supportsStaticESM: false,
rewriteImportExtensions: true,
jsxRuntime: 'automatic',
codegenEnabled: true,
},
configFile: false,
babelrc: false,
plugins: [
'@babel/plugin-syntax-typescript',
[plugin, { extension: 'mjs' }],
],
});
const expected = await fs.promises.readFile(path.resolve(import.meta.dirname, `../__fixtures__/project/code/$${name}-output.ts`), 'utf8');
expect(result?.code).toEqual(expected.trim());
});
//# sourceMappingURL=babel.test.js.map