-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
166 additions
and
48 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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { | ||
getHmrOverlay, | ||
getHmrOverlayText, | ||
killServer, | ||
pollingUntil, | ||
preTest, | ||
viteBuild, | ||
viteServe, | ||
stripedLog, | ||
resetTerminalLog, | ||
} from '../../../packages/vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox' | ||
import { | ||
editFile, | ||
sleep, | ||
testDir, | ||
WORKER_CLEAN_TIMEOUT, | ||
} from '../../../packages/vite-plugin-checker/__tests__/e2e/testUtils' | ||
import { copyCode } from '../../../scripts/jestSetupFilesAfterEnv' | ||
|
||
beforeAll(async () => { | ||
await preTest() | ||
}) | ||
|
||
afterAll(async () => { | ||
await sleep(WORKER_CLEAN_TIMEOUT) | ||
}) | ||
|
||
describe('eslint', () => { | ||
describe('serve', () => { | ||
beforeEach(async () => { | ||
await copyCode() | ||
}) | ||
|
||
afterEach(async () => { | ||
await killServer() | ||
}) | ||
|
||
const snapshot = { | ||
errorCode1: `var hello = 'Hello'`, | ||
errorCode2: '', | ||
absPath: 'vanilla-ts/src/main.ts:3:1', | ||
relativePath: 'src/main.ts:3:1', | ||
errorMsg: `Unexpected var, use let or const instead.`, | ||
} | ||
|
||
// it('get initial error and subsequent error', async () => { | ||
// await viteServe({ cwd: testDir }) | ||
// await pollingUntil(getHmrOverlay, (dom) => !!dom) | ||
// const [message1, file1, frame1] = await getHmrOverlayText() | ||
// expect(message1).toContain(snapshot.errorMsg) | ||
// expect(file1).toContain(snapshot.absPath) | ||
// expect(frame1).toContain(snapshot.errorCode1) | ||
// expect(stripedLog).toContain(snapshot.errorCode1) | ||
// expect(stripedLog).toContain(snapshot.errorMsg) | ||
// expect(stripedLog).toContain(snapshot.relativePath) | ||
|
||
// resetTerminalLog() | ||
// editFile('src/App.tsx', (code) => code.replace('useState<string>(1)', 'useState<string>(2)')) | ||
// await sleep(2000) | ||
// const [, , frame2] = await getHmrOverlayText() | ||
// expect(frame2).toContain(snapshot.errorCode2) | ||
// expect(stripedLog).toContain(snapshot.errorCode2) | ||
// }) | ||
|
||
it('overlay: false', async () => { | ||
resetTerminalLog() | ||
editFile('vite.config.ts', (code) => | ||
code.replace('eslint: true,', 'eslint: true, overlay: false,') | ||
) | ||
|
||
await viteServe({ cwd: testDir }) | ||
await sleep(6000) | ||
await expect(getHmrOverlayText()).rejects.toThrow( | ||
'<vite-error-overlay> shadow dom is expected to be found, but got null' | ||
) | ||
|
||
expect(stripedLog).toContain(snapshot.errorCode1) | ||
expect(stripedLog).toContain(snapshot.errorMsg) | ||
expect(stripedLog).toContain(snapshot.relativePath) | ||
|
||
resetTerminalLog() | ||
editFile('src/main.ts', (code) => code.replace('var hello', 'const hello')) | ||
await sleep(2000) | ||
expect(stripedLog).toContain(snapshot.errorCode2) | ||
}) | ||
}) | ||
|
||
describe('build', () => { | ||
beforeEach(async () => { | ||
await copyCode() | ||
}) | ||
|
||
const expectedMsg = 'Unexpected var, use let or const instead no-var' | ||
|
||
it('enableBuild: true', async () => { | ||
await viteBuild({ expectedErrorMsg: expectedMsg, cwd: testDir }) | ||
}) | ||
|
||
it('enableBuild: false', async () => { | ||
editFile('vite.config.ts', (code) => | ||
code.replace('eslint: {', 'enableBuild: false, eslint: {') | ||
) | ||
await viteBuild({ unexpectedErrorMsg: expectedMsg, cwd: testDir }) | ||
}) | ||
}) | ||
}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { defineConfig } from 'vite' | ||
import reactRefresh from '@vitejs/plugin-react-refresh' | ||
import Checker from 'vite-plugin-checker' | ||
import checker from 'vite-plugin-checker' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [ | ||
reactRefresh(), | ||
Checker({ | ||
typescript: true, | ||
eslint: true, | ||
checker({ | ||
eslint: { | ||
files: ['./src'], | ||
ext: '.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
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
Oops, something went wrong.