Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: init @vitest/browser package #1302

Merged
merged 62 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3fb433d
feat: @vitest/web pacakge
antfu May 13, 2022
a7132a5
chore: test
antfu May 13, 2022
1698d57
chore: api
antfu May 13, 2022
3418f53
Merge branch 'main' into feat/web-runner
antfu May 13, 2022
064c134
Merge branch 'main' into feat/web-runner
antfu May 13, 2022
4d13a9d
chore: lint
antfu May 13, 2022
82c82a8
chore: rename package
antfu May 13, 2022
75daf6a
chore: update
antfu May 14, 2022
89eb5cb
chore: update
antfu May 14, 2022
bc12de6
chore: update
antfu May 14, 2022
948a115
chore: update
antfu May 14, 2022
2abbcc7
Merge branch 'main' into feat/web-runner
antfu May 14, 2022
ba6d38f
chore: lint
antfu May 14, 2022
953c6fc
chore: update packing
antfu May 14, 2022
e3ae867
chore: update
antfu May 14, 2022
965dfb0
chore: update
antfu May 14, 2022
5ba7615
chore: lint
antfu May 14, 2022
9beb276
Merge branch 'main' into feat/web-runner
antfu May 14, 2022
2e50b09
Merge branch 'main' into feat/web-runner
antfu May 14, 2022
6fb61cf
chore: ui on browser
userquin May 14, 2022
4898931
Merge branch 'main' into feat/web-runner
userquin May 14, 2022
8fe28f8
chore: add `node:util` polyfill
userquin May 14, 2022
acca53c
chore: fix lint `util.js` polyfill
userquin May 14, 2022
10e9043
chore: fix lint tsconfig.json on test/browser
userquin May 14, 2022
9b6fc09
chore: exclude browser test from `test:ci`
userquin May 14, 2022
c810b3e
chore: exclude also browser test from `test:ci:no-threads`
userquin May 14, 2022
b771df8
fix: include `rollup-plugin-node-polyfills` to resolve client polyfills
userquin May 15, 2022
63b3ef4
chore: more browser config and is node exclusions
userquin May 15, 2022
0e0e22b
update
Aslemammad Jul 10, 2022
efbd3ef
update
Aslemammad Jul 10, 2022
1eac7dd
fix conflicts
Aslemammad Jul 10, 2022
f38468f
fix conflicts
Aslemammad Jul 10, 2022
6d3a1d0
update
Aslemammad Jul 10, 2022
7a6da8b
fix
Aslemammad Jul 11, 2022
4ba14fc
fix
Aslemammad Jul 11, 2022
49b95c5
fix
Aslemammad Jul 11, 2022
c346177
fix
Aslemammad Jul 11, 2022
3448849
fix
Aslemammad Jul 11, 2022
12fa279
upate
Aslemammad Jul 11, 2022
3dc9799
upate
Aslemammad Jul 11, 2022
ed8fa0f
upate
Aslemammad Jul 11, 2022
f48fa9f
remove log
Aslemammad Jul 11, 2022
fe8cbb7
lint
Aslemammad Jul 11, 2022
a31f635
lint
Aslemammad Jul 11, 2022
7cef14e
fix: use `fs.promises` on `saveSnapshotFile`
userquin Jul 11, 2022
2227919
docs: add `--browser` to `CLI` entry
userquin Jul 11, 2022
2e40c87
fix: uncomment some code
Aslemammad Jul 15, 2022
1c157e9
feat: modern-node-polyfills
Aslemammad Jul 17, 2022
0c24f09
update
Aslemammad Jul 17, 2022
cc3e336
update
Aslemammad Jul 17, 2022
65a3312
update
Aslemammad Jul 18, 2022
99a9764
chore: add retries to load config
userquin Jul 18, 2022
9d0b5ee
merge pnpm lock
Aslemammad Jul 18, 2022
49cb7e1
merge
Aslemammad Jul 18, 2022
b881e2b
pnpm lock
Aslemammad Jul 18, 2022
89dfe3d
update
Aslemammad Jul 19, 2022
753dfa3
chore: update
antfu Jul 19, 2022
ccb4aaf
chore: wording
antfu Jul 19, 2022
7c3caaf
Merge remote-tracking branch 'upstream/main' into feat/web-runner
Aslemammad Jul 19, 2022
141b37b
update
Aslemammad Jul 19, 2022
5972bae
update
Aslemammad Jul 19, 2022
d30799f
docs: update readme
antfu Jul 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 18 additions & 1 deletion packages/browser/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,25 @@ export const client = createClient(ENTRY_URL, {

const ws = client.ws

async function loadConfig() {
let retries = 5
do {
try {
await new Promise(resolve => setTimeout(resolve, 150))
config = await client.rpc.getConfig()
return
}
catch (_) {
// just ignore
}
}
while (--retries > 0)

throw new Error('cannot load configuration after 5 retries')
}

ws.addEventListener('open', async () => {
config = await client.rpc.getConfig()
await loadConfig()

// @ts-expect-error mocking vitest apis
globalThis.__vitest_worker__ = {
Expand Down
5 changes: 5 additions & 0 deletions packages/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vitest Web Runner</title>
<style>
html {
overflow: hidden;
padding: 0;
margin: 0;
}
body {
padding: 0;
margin: 0;
Expand Down
66 changes: 36 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/browser/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
browser: true,
open: false,
open: true,
},
})