From 605077c53282ed1a18e5976160bc624aa27ad74e Mon Sep 17 00:00:00 2001 From: 9aoy Date: Mon, 2 Dec 2024 11:42:38 +0800 Subject: [PATCH] test: fix unstable build watch case (#504) --- .gitignore | 4 ++-- .../integration/cli/build-watch/build.test.ts | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5c3449f35..ca788a553 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ node_modules/ .eslintcache dist/ -dist-types/ +dist-*/ compiled/ coverage/ doc_build/ @@ -22,4 +22,4 @@ test-results .idea/ .nx/ **/@mf-types -**/@mf-types/** \ No newline at end of file +**/@mf-types/** diff --git a/tests/integration/cli/build-watch/build.test.ts b/tests/integration/cli/build-watch/build.test.ts index 7329f26e3..1b375ad2d 100644 --- a/tests/integration/cli/build-watch/build.test.ts +++ b/tests/integration/cli/build-watch/build.test.ts @@ -7,8 +7,14 @@ import { describe, test } from 'vitest'; describe('build --watch command', async () => { test('basic', async () => { const distPath = path.join(__dirname, 'dist'); + const dist1Path = path.join(__dirname, 'dist-1'); fse.removeSync(distPath); + fse.removeSync(dist1Path); + + const distEsmIndexFile = path.join(__dirname, 'dist/esm/index.js'); + const dist1EsmIndexFile = path.join(__dirname, 'dist-1/esm/index.js'); + const tempConfigFile = path.join(__dirname, 'test-temp-rslib.config.mjs'); fse.outputFileSync( @@ -26,24 +32,26 @@ export default defineConfig({ cwd: __dirname, }); - const distEsmIndexFile = path.join(__dirname, 'dist/esm/index.js'); - await awaitFileExists(distEsmIndexFile); - fse.removeSync(distPath); - fse.outputFileSync( tempConfigFile, `import { defineConfig } from '@rslib/core'; import { generateBundleEsmConfig } from 'test-helper'; export default defineConfig({ - lib: [generateBundleEsmConfig()], + lib: [generateBundleEsmConfig({ + output: { + distPath: { + root: './dist-1/esm', + }, + }, + })], }); `, ); - await awaitFileExists(distEsmIndexFile); + await awaitFileExists(dist1EsmIndexFile); process.kill(); });