()
| 26 | } |
| 27 | |
| 28 | function runTests() { |
| 29 | describe('default behavior', () => { |
| 30 | let output = '' |
| 31 | |
| 32 | beforeAll(async () => { |
| 33 | appPort = await findPort() |
| 34 | app = await launchApp(appDir, appPort, { |
| 35 | onStderr(msg) { |
| 36 | output += msg || '' |
| 37 | }, |
| 38 | onStdout(msg) { |
| 39 | output += msg || '' |
| 40 | }, |
| 41 | }) |
| 42 | }) |
| 43 | afterAll(() => killApp(app)) |
| 44 | |
| 45 | it('should alias components', async () => { |
| 46 | const $ = await get$('/basic-alias') |
| 47 | expect($('body').text()).toMatch(/World/) |
| 48 | }) |
| 49 | |
| 50 | it('should resolve the first item in the array first', async () => { |
| 51 | const $ = await get$('/resolve-order') |
| 52 | expect($('body').text()).toMatch(/Hello from a/) |
| 53 | }) |
| 54 | |
| 55 | it('should resolve the second item as fallback', async () => { |
| 56 | const $ = await get$('/resolve-fallback') |
| 57 | expect($('body').text()).toMatch(/Hello from only b/) |
| 58 | }) |
| 59 | |
| 60 | it('should resolve a single matching alias', async () => { |
| 61 | const $ = await get$('/single-alias') |
| 62 | expect($('body').text()).toMatch(/Hello/) |
| 63 | }) |
| 64 | |
| 65 | it('should have correct module not found error', async () => { |
| 66 | const basicPage = join(appDir, 'pages/basic-alias.js') |
| 67 | const contents = await fs.readFile(basicPage, 'utf8') |
| 68 | |
| 69 | try { |
| 70 | await fs.writeFile(basicPage, contents.replace('@c/world', '@c/worldd')) |
| 71 | |
| 72 | await retry(async () => { |
| 73 | await renderViaHTTP(appPort, '/basic-alias') |
| 74 | expect(stripAnsi(output)).toMatch( |
| 75 | /Module not found: Can't resolve '@c\/worldd'/ |
| 76 | ) |
| 77 | }) |
| 78 | } finally { |
| 79 | await fs.writeFile(basicPage, contents) |
| 80 | } |
| 81 | }) |
| 82 | }) |
| 83 | |
| 84 | describe('should build', () => { |
| 85 | ;(process.env.TURBOPACK_DEV ? describe.skip : describe)( |
no test coverage detected