Skip to content

Commit d2e7999

Browse files
committed
chore: update docs to svelte 5
1 parent 9889ea3 commit d2e7999

File tree

5 files changed

+27
-36
lines changed

5 files changed

+27
-36
lines changed

Diff for: docs/app/component-testing/get-started.mdx

+5-9
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ following development servers and frameworks:
4646
| [Vue with Vite](/app/component-testing/vue/overview#Vue-with-Vite) | Vue 3 | Vite 4-6 |
4747
| [Vue with Webpack](/app/component-testing/vue/overview#Vue-with-Webpack) | Vue 3 | Webpack 4-5 |
4848
| [Angular](/app/component-testing/angular/overview#Framework-Configuration) | Angular 17-19 | Webpack 5 |
49-
| [Svelte with Vite](/app/component-testing/svelte/overview#Svelte-with-Vite) <Badge type="info">Alpha</Badge> | Svelte 4 | Vite 4-6 |
50-
| [Svelte with Webpack](/app/component-testing/svelte/overview#Svelte-with-Webpack) <Badge type="info">Alpha</Badge> | Svelte 4 | Webpack 4-5 |
49+
| [Svelte with Vite](/app/component-testing/svelte/overview#Svelte-with-Vite) <Badge type="info">Alpha</Badge> | Svelte 5 | Vite 4-6 |
50+
| [Svelte with Webpack](/app/component-testing/svelte/overview#Svelte-with-Webpack) <Badge type="info">Alpha</Badge> | Svelte 5 | Webpack 4-5 |
5151

5252
The following integrations are built and maintained by Cypress community members.
5353

@@ -618,14 +618,10 @@ it('clicking + fires a change event with the incremented value', () => {
618618

619619
```js
620620
it('clicking + fires a change event with the incremented value', () => {
621-
const changeSpy = cy.spy().as('changeSpy')
622-
cy.mount(Stepper).then(({ component }) => {
623-
component.$on('change', changeSpy)
624-
})
621+
const onChangeSpy = cy.spy().as('onChangeSpy')
622+
cy.mount(Stepper, { props: { onChange: onChangeSpy } })
625623
cy.get('[data-cy=increment]').click()
626-
cy.get('@changeSpy').should('have.been.calledWithMatch', {
627-
detail: { count: 1 },
628-
})
624+
cy.get('@onChangeSpy').should('have.been.calledWith', 1)
629625
})
630626
```
631627

Diff for: docs/app/component-testing/svelte/api.mdx

+8-10
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ import { mount } from 'cypress/svelte'
2020
<tr>
2121
<td>Signature</td>
2222
<td>
23-
mount&lt;T extends SvelteComponent&gt;(Component:
24-
SvelteConstructor&lt;T&gt;, options?: MountOptions&lt;T&gt;):
25-
Cypress.Chainable&lt;MountReturn&lt;T&gt;&gt;
23+
mount(Component: Component&lt;Record&lt;string, any&gt;, Record&lt;string,
24+
any&gt;, any&gt;, options?: MountOptions):
25+
Cypress.Chainable&lt;MountReturn&gt;
2626
</td>
2727
</tr>
28-
<tr>
29-
<td>Generic Param T</td>
30-
<td>The component type</td>
31-
</tr>
3228
<tr>
3329
<td>Returns</td>
3430
<td>Cypress.Chainable&lt;MountReturn&gt;</td>
@@ -44,12 +40,14 @@ import { mount } from 'cypress/svelte'
4440
</thead>
4541
<tr>
4642
<td>component</td>
47-
<td>SvelteConstructor&lt;T&gt;</td>
43+
<td>
44+
Component&lt;Record&lt;string, any&gt;, Record&lt;string, any&gt;, any&gt;
45+
</td>
4846
<td>Svelte component being mounted</td>
4947
</tr>
5048
<tr>
5149
<td>options</td>
52-
<td>MountOptions&lt;T&gt; (optional)</td>
50+
<td>MountOptions (optional)</td>
5351
<td>options to customize the component being mounted</td>
5452
</tr>
5553
</table>
@@ -117,7 +115,7 @@ Type that the `mount` function yields
117115
</thead>
118116
<tr>
119117
<td>component</td>
120-
<td>T</td>
118+
<td>Record&lt;string, any&gt;</td>
121119
<td></td>
122120
</tr>
123121
</table>

Diff for: docs/app/component-testing/svelte/examples.mdx

+7-10
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,18 @@ it('mounts', () => {
4242

4343
### Testing Event Handlers
4444

45-
To test emitted events from a Svelte component, we can use access the component
46-
instances and use `$on` method to listen to events raised. We can also pass in a
45+
To test emitted events from a Svelte component, we need to pass in a callback
46+
for when we increment the stepper. The Stepper component
47+
will need to invoke this callback for us. We can also pass in a
4748
Cypress spy so we can query the spy later for results. In the example below, we
48-
listen to the `change` event and validate it was called as expected:
49+
pass in the `onChange` callback handler and validate it was called as expected:
4950

5051
```js
5152
it('clicking + fires a change event with the incremented value', () => {
52-
const changeSpy = cy.spy().as('changeSpy')
53-
cy.mount(Stepper).then(({ component }) => {
54-
component.$on('change', changeSpy)
55-
})
53+
const onChangeSpy = cy.spy().as('onChangeSpy')
54+
cy.mount(Stepper, { props: { onChange: onChangeSpy } })
5655
cy.get('[data-cy=increment]').click()
57-
cy.get('@changeSpy').should('have.been.calledWithMatch', {
58-
detail: { count: 1 },
59-
})
56+
cy.get('@onChangeSpy').should('have.been.calledWith', 1)
6057
})
6158
```
6259

Diff for: docs/app/component-testing/svelte/overview.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ sidebar_label: Overview
1616

1717
## Framework Support
1818

19-
Cypress Component Testing supports Svelte 4 in a variety of different
19+
Cypress Component Testing supports Svelte 5 in a variety of different
2020
frameworks:
2121

2222
- [Svelte with Vite](#Svelte-with-Vite)
@@ -93,7 +93,7 @@ bundler.
9393

9494
#### Svelte Vite Sample Apps
9595

96-
- [Svelte 4 Vite 5 with Typescript](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/svelte-vite-ts)
96+
- [Svelte 5 Vite 6 with Typescript](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/svelte-vite-ts)
9797

9898
### Svelte with Webpack
9999

@@ -129,4 +129,4 @@ in manually via the `webpackConfig` option.
129129

130130
#### Svelte Webpack Sample Apps
131131

132-
- [Svelte 4 Webpack 5 with Typescript](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/svelte-webpack-ts)
132+
- [Svelte 5 Webpack 5 with Typescript](https://github.com/cypress-io/cypress-component-testing-apps/tree/main/svelte-webpack-ts)

Diff for: docs/app/references/migration-guide.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,17 @@ module.exports = defineConfig({
246246
})
247247
```
248248

249-
### Svelte 3 for Component Testing is no longer supported
249+
### Svelte 3 and 4 for Component Testing is no longer supported
250250

251-
With Cypress 14, Cypress no longer ships the Svelte 3 component testing harness with the Cypress binary.
251+
With Cypress 14, Cypress no longer ships the Svelte 3 and 4 component testing harness with the Cypress binary.
252252

253-
However, if you have not been able to upgrade Svelte and still need the Cypress Svelte 3 test harness, it can be installed independently via version 2.x.x of the [@cypress/svelte](https://www.npmjs.com/package/@cypress/svelte) package.
253+
However, if you have not been able to upgrade Svelte and still need the Cypress Svelte 3 and 4 test harness, it can be installed independently via version 2.x.x of the [@cypress/svelte](https://www.npmjs.com/package/@cypress/svelte) package.
254254

255255
```sh
256256
npm install --save-dev @cypress/svelte@2
257257
```
258258

259-
Note that this version of the test harness is deprecated and no longer actively supported by Cypress and is intended to serve as a temporary work around until you are able to migrate your project to Svelte 4+. The Cypress launchpad will also warn against Component testing mismatched dependencies, but this will not stop you from running your component tests.
259+
Note that this version of the test harness is deprecated and no longer actively supported by Cypress and is intended to serve as a temporary work around until you are able to migrate your project to Svelte 5+. The Cypress launchpad will also warn against Component testing mismatched dependencies, but this will not stop you from running your component tests.
260260

261261
To update, inside your support file (ex: `./cypress/support/component.(js|ts)`) or wherever your mount function is imported, change
262262

0 commit comments

Comments
 (0)