Skip to content

Commit

Permalink
test: fix unstable build watch case (#504)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy authored Dec 2, 2024
1 parent 97909c2 commit 605077c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node_modules/
.eslintcache

dist/
dist-types/
dist-*/
compiled/
coverage/
doc_build/
Expand All @@ -22,4 +22,4 @@ test-results
.idea/
.nx/
**/@mf-types
**/@mf-types/**
**/@mf-types/**
20 changes: 14 additions & 6 deletions tests/integration/cli/build-watch/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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();
});
Expand Down

0 comments on commit 605077c

Please sign in to comment.