Skip to content

add testing sponsor lambdatest #2438

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

Merged
merged 1 commit into from
Nov 29, 2024
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
113 changes: 75 additions & 38 deletions src/guide/scaling-up/testing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
<script setup>
import { VTCodeGroup, VTCodeGroupTab } from '@vue/theme'
</script>
<style>
.lambdatest {
background-color: var(--vt-c-bg-soft);
border-radius: 8px;
padding: 12px 16px 12px 12px;
font-size: 13px;
a {
display: flex;
color: var(--vt-c-text-2);
}
img {
background-color: #fff;
padding: 12px 16px;
border-radius: 6px;
margin-right: 24px;
}
.testing-partner {
color: var(--vt-c-text-1);
font-size: 15px;
font-weight: 600;
}
}
</style>

# テスト {#testing}

Expand Down Expand Up @@ -40,7 +63,7 @@ Vue アプリケーションのテスト戦略を設計する際には、以下

```js
// helpers.js
export function increment (current, max = 10) {
export function increment(current, max = 10) {
if (current < max) {
return current + 1
}
Expand Down Expand Up @@ -129,62 +152,66 @@ Vue アプリケーションでは、コンポーネントは UI の主要な構
<VTCodeGroup>
<VTCodeGroupTab label="Vue Test Utils">

```js
const valueSelector = '[data-testid=stepper-value]'
const buttonSelector = '[data-testid=increment]'
```js
const valueSelector = '[data-testid=stepper-value]'
const buttonSelector = '[data-testid=increment]'

const wrapper = mount(Stepper, {
props: {
max: 1
}
})
const wrapper = mount(Stepper, {
props: {
max: 1
}
})

expect(wrapper.find(valueSelector).text()).toContain('0')
expect(wrapper.find(valueSelector).text()).toContain('0')

await wrapper.find(buttonSelector).trigger('click')
await wrapper.find(buttonSelector).trigger('click')

expect(wrapper.find(valueSelector).text()).toContain('1')
```
expect(wrapper.find(valueSelector).text()).toContain('1')
```

</VTCodeGroupTab>
<VTCodeGroupTab label="Cypress">

```js
const valueSelector = '[data-testid=stepper-value]'
const buttonSelector = '[data-testid=increment]'
```js
const valueSelector = '[data-testid=stepper-value]'
const buttonSelector = '[data-testid=increment]'

mount(Stepper, {
props: {
max: 1
}
})
mount(Stepper, {
props: {
max: 1
}
})

cy.get(valueSelector).should('be.visible').and('contain.text', '0')
.get(buttonSelector).click()
.get(valueSelector).should('contain.text', '1')
```
cy.get(valueSelector)
.should('be.visible')
.and('contain.text', '0')
.get(buttonSelector)
.click()
.get(valueSelector)
.should('contain.text', '1')
```

</VTCodeGroupTab>
<VTCodeGroupTab label="Testing Library">

```js
const { getByText } = render(Stepper, {
props: {
max: 1
}
})
```js
const { getByText } = render(Stepper, {
props: {
max: 1
}
})

getByText('0') // // コンポーネント内に "0 "があることを暗黙のうちに評価します
getByText('0') // // コンポーネント内に "0 "があることを暗黙のうちに評価します

const button = getByRole('button', { name: /increment/i })
const button = getByRole('button', { name: /increment/i })

// インクリメントボタンにクリックイベントをディスパッチします。
await fireEvent.click(button)
// インクリメントボタンにクリックイベントをディスパッチします。
await fireEvent.click(button)

getByText('1')
getByText('1')

await fireEvent.click(button)
```
await fireEvent.click(button)
```

</VTCodeGroupTab>
</VTCodeGroup>
Expand Down Expand Up @@ -265,6 +292,16 @@ Vitest とブラウザーベースのランナーの主な違いは、スピー

- [Cypress](https://www.cypress.io/) は、情報豊富なグラフィカルインターフェース、優れたデバッグ性、組み込みアサーションとスタブ、耐フレーク性(flake-resistance)、スナップショットなどの機能を備えています。また、前述の通り[コンポーネントテスト](https://docs.cypress.io/guides/component-testing/introduction)もサポートしています。Chromium ベースのブラウザー、Firefox、Electron をサポートしています。WebKit のサポートもありますが、実験的機能とされています。Cypress は MIT ライセンスですが、並列化などの一部の機能には Cypress Cloud へのサブスクリプションが必要です。

<div class="lambdatest">
<a href="https://lambdatest.com" target="_blank">
<img src="/images/lambdatest.svg">
<div>
<div class="testing-partner">Testing Sponsor</div>
<div>Lambdatest は、AI 支援によるテスト生成機能を備え、主要なブラウザと実機を対象に、E2E、アクセシビリティ、Visual Regression Test を実行するためのクラウドプラットフォームです!</div>
</div>
</a>
</div>

### その他の選択肢 {#other-options-2}

- [Nightwatch](https://nightwatchjs.org/) は、[Selenium WebDriver](https://www.npmjs.com/package/selenium-webdriver) をベースとした E2E テストソリューションです。こちらはネイティブモバイルテストを含む、最も広い範囲のブラウザーをサポートしています。Selenium ベースのソリューションは、Playwright や Cypress よりも遅くなります。
Expand Down
Loading