Skip to content

Commit

Permalink
Added a test for livereload
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane Osbourne committed Aug 19, 2024
1 parent fee3b56 commit 91b4488
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
13 changes: 13 additions & 0 deletions examples/basic/live-reload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
servers:
- name: 'live-reload'
routes:
- path: /
html: |
<head>
<link href="/styles.css" rel="stylesheet" />
</head>
<body>hey from live-reload!</body>
- path: /reset.css
dir: examples/basic/public/reset.css
- path: /styles.css
dir: examples/basic/public/styles.css
2 changes: 1 addition & 1 deletion examples/basic/public/styles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import url("reset.css");
@import url("./reset.css");

/** your styles here */
20 changes: 20 additions & 0 deletions tests/examples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,23 @@ test.describe('examples/basic/inject.yml', {
}
});
})

test.describe('examples/basic/live-reload.yml', {
annotation: {
type: bstest({
input: 'examples/basic/live-reload.yml'
}),
description: ''
}
}, () => {
test('live-reloading css', async ({page, bs}) => {
await page.goto(bs.path('/'), {waitUntil: 'networkidle'})
const requestPromise = page.waitForRequest((req) => {
const url = new URL(req.url());
return url.searchParams.has('livereload')
&& url.pathname === "/styles.css"
}, {timeout: 2000});
bs.touch('examples/basic/public/styles.css')
await requestPromise;
});
})
2 changes: 1 addition & 1 deletion tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const test = base.extend<{
},
stdout,
touch: (path: string) => {
touchFile(join('msg.cwd', path));
touchFile(join(cwd, path));
},
});

Expand Down

0 comments on commit 91b4488

Please sign in to comment.