Skip to content

Commit 934207d

Browse files
committed
test(e2e): add e2e test
1 parent af425dc commit 934207d

File tree

9 files changed

+47
-6
lines changed

9 files changed

+47
-6
lines changed
Lines changed: 7 additions & 0 deletions
Loading

examples/preact-component-bundle-false/src/components/CounterButton/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { FunctionComponent } from 'preact';
2+
import logo from '../../assets/logo.svg';
23
import styles from './index.module.scss';
34

45
interface CounterButtonProps {
@@ -10,7 +11,12 @@ export const CounterButton: FunctionComponent<CounterButtonProps> = ({
1011
onClick,
1112
label,
1213
}) => (
13-
<button type="button" className={styles.button} onClick={onClick}>
14+
<button
15+
type="button"
16+
className={`${styles.button} counter-button`}
17+
onClick={onClick}
18+
>
19+
<img src={logo} alt="react" />
1420
{label}
1521
</button>
1622
);

examples/preact-component-bundle-false/src/env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ declare module '*.module.scss' {
22
const classes: { [key: string]: string };
33
export default classes;
44
}
5+
6+
declare module '*.svg' {
7+
const url: string;
8+
export default url;
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
.counter-title {
2+
width: 100px;
3+
height: 100px;
4+
background: no-repeat url('./assets/logo.svg');
5+
background-size: cover;
6+
}
7+
18
.counter-text {
29
font-size: 50px;
310
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.button {
2-
background: url('../../assets/logo.svg') no-repeat;
2+
background: yellow;
33
}

examples/react-component-bundle-false/src/components/CounterButton/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
1111
onClick,
1212
label,
1313
}) => (
14-
<button type="button" className={styles.button} onClick={onClick}>
14+
<button
15+
type="button"
16+
className={`${styles.button} counter-button`}
17+
onClick={onClick}
18+
>
1519
<img src={logo} alt="react" />
1620
{label}
1721
</button>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.button {
2-
background: url('../../assets/logo.svg') no-repeat;
2+
background: yellow;
33
}

examples/react-component-bundle/src/components/CounterButton/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ export const CounterButton: React.FC<CounterButtonProps> = ({
1111
onClick,
1212
label,
1313
}) => (
14-
<button type="button" className={styles.button} onClick={onClick}>
14+
<button
15+
type="button"
16+
className={`${styles.button} counter-button`}
17+
onClick={onClick}
18+
>
1519
<img src={logo} alt="react" />
1620
{label}
1721
</button>

tests/e2e/react-component/index.pw.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ async function assetShouldWork(page: Page) {
4040
assert(h1El);
4141
expect(h1El).toHaveCSS('background', /static\/svg\/logo/);
4242

43-
// TODO: asset in js
43+
// asset by import url from './assets/logo.svg'
44+
const imgEls = await page.$$('.counter-button>img');
45+
expect(imgEls).toHaveLength(2);
46+
const srcList = await Promise.all(
47+
imgEls.map((imgEl) => imgEl.getAttribute('src')),
48+
)
49+
for (const src of srcList) {
50+
expect(src).toMatch(/static\/svg\/logo/);
51+
}
4452
}
4553

4654
test('should render example "react-component-bundle" successfully', async ({

0 commit comments

Comments
 (0)