Skip to content

Commit

Permalink
fix: overlay.initialIsOpen is not work
Browse files Browse the repository at this point in the history
  • Loading branch information
fi3ework committed Feb 7, 2022
1 parent 44f499a commit 9383440
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/runtime/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import List from './components/List.svelte'
import Badge from './components/Badge.svelte'
export let overlayConfig = {}
export let initialIsOpen = true
export let checkerResults
let collapsed = !initialIsOpen
const initialIsOpen = overlayConfig?.initialIsOpen ?? true
$: collapsed = !initialIsOpen
const toggle = () => {
collapsed = !collapsed
}
Expand Down
1 change: 0 additions & 1 deletion packages/runtime/src/components/List.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<ul style={ulStyle}>
{#each checkerResults as checkerResult, index}
<li>
{(console.log(checkerResult), '')}
<Checker diagnostics={checkerResult.diagnostics} {index} />
</li>
{/each}
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-plugin-checker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-checker",
"version": "0.4.0-beta.2",
"version": "0.4.0-beta.3",
"description": "Vite plugin that runs TypeScript type checker on a separate process.",
"main": "lib/main.js",
"bin": {
Expand Down
5 changes: 0 additions & 5 deletions playground/basic/__tests__/__snapshots__/dev.spec.ts.snap

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`overlay-initialIsOpen-false serve get initial error and subsequent error 1`] = `""`;

exports[`overlay-initialIsOpen-false serve get initial error and subsequent error 2`] = `""`;

exports[`overlay-initialIsOpen-false serve get initial error and subsequent error 3`] = `""`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`overlay-terminal-false serve get initial error and subsequent error 1`] = `"[{\\"checkerId\\":\\"ESLint\\",\\"frame\\":\\" 1 | import { text } from './text'/n 2 |/n > 3 | var hello = 'Hello'/n | ^^^^^^^^^^^^^^^^^^^/n 4 |/n 5 | const rootDom = document.querySelector('#root')! as HTMLElement/n 6 | rootDom.innerHTML = hello + text\\",\\"id\\":\\"<PROJECT_ROOT>/temp/basic/src/main.ts\\",\\"level\\":1,\\"loc\\":{\\"column\\":1,\\"file\\":\\"<PROJECT_ROOT>/temp/basic/src/main.ts\\",\\"line\\":3},\\"message\\":\\"Unexpected var, use let or const instead.\\",\\"stack\\":\\"\\"},{\\"checkerId\\":\\"ESLint\\",\\"frame\\":\\" 3 | var hello = 'Hello'/n 4 |/n > 5 | const rootDom = document.querySelector('#root')! as HTMLElement/n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/n 6 | rootDom.innerHTML = hello + text/n 7 |/n 8 | export {}\\",\\"id\\":\\"<PROJECT_ROOT>/temp/basic/src/main.ts\\",\\"level\\":0,\\"loc\\":{\\"column\\":17,\\"file\\":\\"<PROJECT_ROOT>/temp/basic/src/main.ts\\",\\"line\\":5},\\"message\\":\\"Forbidden non-null assertion.\\",\\"stack\\":\\"\\"}]"`;

exports[`overlay-terminal-false serve get initial error and subsequent error 2`] = `""`;
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ afterAll(async () => {
await sleep(WORKER_CLEAN_TIMEOUT)
})

describe('enableBuild', () => {
describe('enableBuild-false', () => {
beforeEach(async () => {
await copyCode()
})

it('enableBuild: false', async () => {
it('test', async () => {
editFile('vite.config.ts', (code) => code.replace(`// edit-slot`, `enableBuild: false,`))
await viteBuild({
unexpectedErrorMsg: 'error',
Expand Down
53 changes: 53 additions & 0 deletions playground/basic/__tests__/overlay-initialIsOpen-false.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* eslint-disable max-nested-callbacks */
import {
getHmrOverlayText,
killServer,
preTest,
viteServe,
} from 'vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox'
import {
editFile,
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('overlay-initialIsOpen-false', () => {
beforeEach(async () => {
await copyCode()
})

describe('serve', () => {
afterEach(async () => {
await killServer()
})

it('get initial error and subsequent error', async () => {
editFile('vite.config.ts', (code) =>
code.replace(`// edit-slot`, `overlay: { initialIsOpen: false },`)
)
await viteServe({
cwd: testDir,
launchPage: true,
})
await sleep(6000)
const [message, file, frame] = await getHmrOverlayText()
expect(message).toMatchSnapshot()
expect(file).toMatchSnapshot()
expect(frame).toMatchSnapshot()
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
proxyConsoleInTest,
sleepForServerReady,
stripedLog,
viteBuild,
viteServe,
} from 'vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox'
import {
Expand All @@ -30,7 +29,7 @@ afterAll(async () => {
await sleep(WORKER_CLEAN_TIMEOUT)
})

describe('config-dev', () => {
describe('overlay-terminal-false', () => {
beforeEach(async () => {
await copyCode()
})
Expand All @@ -42,9 +41,7 @@ describe('config-dev', () => {

it('get initial error and subsequent error', async () => {
let diagnostics: any
editFile('vite.config.ts', (code) =>
code.replace(`// edit-slot`, `overlay: false, terminal: false,`)
)
editFile('vite.config.ts', (code) => code.replace(`// edit-slot`, `terminal: false,`))
await viteServe({
cwd: testDir,
proxyConsole: () => proxyConsoleInTest(true),
Expand All @@ -59,11 +56,4 @@ describe('config-dev', () => {
expect(stripedLog).toMatchSnapshot()
})
})

describe('build', () => {
it('enableBuild: false', async () => {
const expectedMsg = 'Unexpected var, use let or const instead no-var'
await viteBuild({ expectedErrorMsg: expectedMsg, cwd: testDir })
})
})
})

0 comments on commit 9383440

Please sign in to comment.