Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,15 @@ export default defineVitestConfig({
```typescript
// vitest-setup.ts

// Load Stencil components.
// Adjust according to your build output of choice *
await import('./dist/test-components/test-components.esm.js');
// Load your components' lazy-loader build.
// Stencil v5: dist/loader-bundle/<namespace>/<namespace>.js
// Stencil v4: dist/<namespace>/<namespace>.esm.js
await import('./dist/loader-bundle/test-components/test-components.js');

export {};
// * Bear in mind, you may need `buildDist: true` (in your stencil.config)
// or `--prod` to use an output other than the browser lazy-loader
// To test against a different output target, set `skipInDev: false` on it in your
// stencil.config (Stencil v4: `buildDist: true`), or run with `--prod`.
// Development builds skip those outputs otherwise.
```

### 4. Write Tests
Expand Down Expand Up @@ -231,11 +233,11 @@ Spy on component methods, props, and lifecycle hooks to verify behaviour without
>
> ```diff
> // vitest-setup.ts
> - await import('./dist/test-components/test-components.esm.js');
> - await import('./dist/loader-bundle/test-components/test-components.js');
>
> + import { beforeAll } from 'vitest';
> + beforeAll(async () => {
> + await import('./dist/test-components/test-components.esm.js');
> + await import('./dist/loader-bundle/test-components/test-components.js');
> + });
> ```

Expand Down
5 changes: 3 additions & 2 deletions src/testing/html-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ export function prettifyHtml(html: string): string {
}

/**
* Normalize HTML for comparison by removing extra whitespace
* Normalize HTML for comparison by removing extra whitespace,
* including whitespace between a tag and its text content
*/
export function normalizeHtml(html: string): string {
return html.replace(/\s+/g, ' ').replace(/>\s+</g, '><').trim();
return html.replace(/\s+/g, ' ').replace(/>\s+/g, '>').replace(/\s+</g, '<').trim();
}
Loading