|
1 | 1 | import { join } from 'node:path'; |
2 | 2 | import { buildAndGetResults } from '@e2e/helper'; |
3 | | -import { expect, test } from 'vitest'; |
| 3 | +import { describe, expect, test } from 'vitest'; |
4 | 4 |
|
5 | | -test('dts when bundle: false', async () => { |
6 | | - const fixturePath = join(__dirname, 'bundle-false'); |
7 | | - const { files, contents } = await buildAndGetResults(fixturePath, 'dts'); |
| 5 | +describe('dts when bundle: false', () => { |
| 6 | + test('basic - bundleless dts', async () => { |
| 7 | + const fixturePath = join(__dirname, 'bundle-false'); |
| 8 | + const { files, contents } = await buildAndGetResults( |
| 9 | + fixturePath, |
| 10 | + 'rslib.config.ts', |
| 11 | + 'dts', |
| 12 | + ); |
8 | 13 |
|
9 | | - expect(files.esm?.length).toBe(4); |
10 | | - expect(files.esm?.[0]!.endsWith('.d.ts')).toEqual(true); |
11 | | - expect(contents.esm).toMatchSnapshot(); |
| 14 | + expect(files.esm?.length).toBe(4); |
| 15 | + expect(files.esm?.[0]!.endsWith('.d.ts')).toEqual(true); |
| 16 | + expect(contents.esm).toMatchSnapshot(); |
| 17 | + }); |
| 18 | + |
| 19 | + test('dts false - bundleless dts', async () => { |
| 20 | + const fixturePath = join(__dirname, 'bundle-false'); |
| 21 | + const { files } = await buildAndGetResults( |
| 22 | + fixturePath, |
| 23 | + 'rslib.false.config.ts', |
| 24 | + 'dts', |
| 25 | + ); |
| 26 | + |
| 27 | + expect(files.esm).toBe(undefined); |
| 28 | + }); |
| 29 | + |
| 30 | + test('distPath - bundleless dts', async () => { |
| 31 | + const fixturePath = join(__dirname, 'bundle-false'); |
| 32 | + const { files } = await buildAndGetResults( |
| 33 | + fixturePath, |
| 34 | + 'rslib.distpath.config.ts', |
| 35 | + 'dts', |
| 36 | + ); |
| 37 | + expect(files.esm?.length).toBe(4); |
| 38 | + expect(files.esm?.[0]!.startsWith('./dist/custom')).toEqual(true); |
| 39 | + }); |
12 | 40 | }); |
13 | 41 |
|
14 | | -test('dts when bundle: true', async () => { |
15 | | - const fixturePath = join(__dirname, 'bundle'); |
16 | | - const { entryFiles, entries } = await buildAndGetResults(fixturePath, 'dts'); |
| 42 | +describe('dts when bundle: true', () => { |
| 43 | + test('basic - bundle dts', async () => { |
| 44 | + const fixturePath = join(__dirname, 'bundle'); |
| 45 | + const { entryFiles, entries } = await buildAndGetResults( |
| 46 | + fixturePath, |
| 47 | + 'rslib.config.ts', |
| 48 | + 'dts', |
| 49 | + ); |
| 50 | + |
| 51 | + expect(entryFiles.esm!.endsWith('index.d.ts')).toEqual(true); |
| 52 | + expect(entries).toMatchSnapshot(); |
| 53 | + }); |
| 54 | + |
| 55 | + test('dts false - bundle dts', async () => { |
| 56 | + const fixturePath = join(__dirname, 'bundle'); |
| 57 | + const { entryFiles } = await buildAndGetResults( |
| 58 | + fixturePath, |
| 59 | + 'rslib.false.config.ts', |
| 60 | + 'dts', |
| 61 | + ); |
| 62 | + |
| 63 | + expect(entryFiles.esm).toEqual(undefined); |
| 64 | + }); |
| 65 | + |
| 66 | + test('distPath - bundle dts', async () => { |
| 67 | + const fixturePath = join(__dirname, 'bundle'); |
| 68 | + const { entryFiles } = await buildAndGetResults( |
| 69 | + fixturePath, |
| 70 | + 'rslib.distpath.config.ts', |
| 71 | + 'dts', |
| 72 | + ); |
17 | 73 |
|
18 | | - expect(entryFiles.esm!.endsWith('index.d.ts')).toEqual(true); |
19 | | - expect(entries).toMatchSnapshot(); |
| 74 | + expect(entryFiles.esm!.startsWith('./dist/custom')).toEqual(true); |
| 75 | + }); |
20 | 76 | }); |
0 commit comments