-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add case for no runtime code in build
- Loading branch information
Showing
4 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
playground/basic/__tests__/no-runtime-code-in-build.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import fs from 'fs/promises' | ||
import klaw from 'klaw' | ||
import path from 'path' | ||
import { preTest, viteBuild } from 'vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox' | ||
import { | ||
editFileTo, | ||
sleep, | ||
testDir, | ||
WORKER_CLEAN_TIMEOUT, | ||
} from 'vite-plugin-checker/__tests__/e2e/testUtils' | ||
|
||
import { copyCode } from '../../../scripts/jestSetupFilesAfterEnv' | ||
import { serializers } from '../../../scripts/serializers' | ||
|
||
beforeAll(async () => { | ||
await preTest() | ||
}) | ||
|
||
expect.addSnapshotSerializer(serializers) | ||
|
||
afterAll(async () => { | ||
await sleep(WORKER_CLEAN_TIMEOUT) | ||
}) | ||
|
||
describe('no-runtime-code-in-build', () => { | ||
beforeEach(async () => { | ||
await copyCode() | ||
}) | ||
|
||
it('test', async () => { | ||
editFileTo('src/main.ts', `import { text } from './text'; console.log(text); export {}`) | ||
await viteBuild({ | ||
cwd: testDir, | ||
}) | ||
|
||
for await (const file of klaw(path.resolve(testDir, 'dist'))) { | ||
if (file.stats.isFile()) { | ||
const content = await fs.readFile(file.path, 'utf-8') | ||
expect(content).not.toContain('vite-plugin-checker') | ||
} | ||
} | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.