|
1 | 1 | import path from 'node:path'; |
2 | 2 | import { pathToFileURL } from 'node:url'; |
3 | | -import { expect, it } from 'vitest'; |
| 3 | +import { describe, expect, it } from 'vitest'; |
4 | 4 | import { transpileTypeScriptFile } from '../src/transpile'; |
5 | 5 |
|
6 | | -it('should transpile basic typescript file', async () => { |
7 | | - const url = pathToFileURL(path.join(__dirname, 'fixtures', 'basic.ts')); |
8 | | - const { format, source } = await transpileTypeScriptFile(url.toString()); |
9 | | - expect(format).toMatchInlineSnapshot(`"module"`); |
10 | | - expect(source.trim()).toMatchInlineSnapshot(`"export const str = 'ing';"`); |
11 | | -}); |
| 6 | +describe.skipIf(process.env['LEAK_TEST'])('Transpile', () => { |
| 7 | + it('should transpile basic typescript file', async () => { |
| 8 | + const url = pathToFileURL(path.join(__dirname, 'fixtures', 'basic.ts')); |
| 9 | + const { format, source } = await transpileTypeScriptFile(url.toString()); |
| 10 | + expect(format).toMatchInlineSnapshot(`"module"`); |
| 11 | + expect(source.trim()).toMatchInlineSnapshot(`"export const str = 'ing';"`); |
| 12 | + }); |
12 | 13 |
|
13 | | -it.skipIf( |
14 | | - // bun has issues with the snapshot. it looks exactly the same but bun claims it doesnt match |
15 | | - globalThis.Bun, |
16 | | -)('should transpile basic typescript commonjs file', async () => { |
17 | | - const url = pathToFileURL(path.join(__dirname, 'fixtures', 'basic.cts')); |
18 | | - const { format, source } = await transpileTypeScriptFile(url.toString()); |
19 | | - expect(format).toMatchInlineSnapshot(`"commonjs"`); |
20 | | - expect(source.trim()).toMatchInlineSnapshot(` |
21 | | -""use strict";const str = 'ing'; |
22 | | -module.exports = { str };"`); |
23 | | -}); |
| 14 | + it.skipIf( |
| 15 | + // bun has issues with the snapshot. it looks exactly the same but bun claims it doesnt match |
| 16 | + globalThis.Bun, |
| 17 | + )('should transpile basic typescript commonjs file', async () => { |
| 18 | + const url = pathToFileURL(path.join(__dirname, 'fixtures', 'basic.cts')); |
| 19 | + const { format, source } = await transpileTypeScriptFile(url.toString()); |
| 20 | + expect(format).toMatchInlineSnapshot(`"commonjs"`); |
| 21 | + expect(source.trim()).toMatchInlineSnapshot(` |
| 22 | + ""use strict";const str = 'ing'; |
| 23 | + module.exports = { str };"`); |
| 24 | + }); |
24 | 25 |
|
25 | | -it('should fail transpiling typescript file with syntax error and file location', async () => { |
26 | | - const url = pathToFileURL( |
27 | | - path.join(__dirname, 'fixtures', 'syntax-error.ts'), |
28 | | - ); |
29 | | - await expect(transpileTypeScriptFile(url.toString())).rejects.toThrowError( |
30 | | - // we include the starting forwardslash and the project path because we want to make sure the absolute path is reported |
31 | | - /Error transforming \/(.*)\/packages\/importer\/tests\/fixtures\/syntax-error.ts: Unexpected token, expected ";" \(2:11\)/, |
32 | | - ); |
| 26 | + it('should fail transpiling typescript file with syntax error and file location', async () => { |
| 27 | + const url = pathToFileURL( |
| 28 | + path.join(__dirname, 'fixtures', 'syntax-error.ts'), |
| 29 | + ); |
| 30 | + await expect(transpileTypeScriptFile(url.toString())).rejects.toThrowError( |
| 31 | + // we include the starting forwardslash and the project path because we want to make sure the absolute path is reported |
| 32 | + /Error transforming \/(.*)\/packages\/importer\/tests\/fixtures\/syntax-error.ts: Unexpected token, expected ";" \(2:11\)/, |
| 33 | + ); |
| 34 | + }); |
33 | 35 | }); |
0 commit comments