@react-native-gpui /测试
测试React Native桌面应用程序:启动真正的应用程序并从Vitest驱动它,或者使用Vitest预设对组件进行单元测试。
的一部分 react-native-gpui, macOS, Windows和Linux的React Native。
安装
用CLI创建的应用程序已经设置好了。在现有的应用程序中:
npm install --save-dev @react-native-gpui/testing vitest
使用
import { afterAll, beforeAll, test } from 'vitest';
import { launchApp, expect, type DesktopApp } from '@react-native-gpui/testing';
let app: DesktopApp;
beforeAll(async () => {
app = await launchApp({ disableAnimations: true });
});
afterAll(() => app.close());
test('counts presses', async () => {
await app.getByText('Increment').click();
await expect(app.getByTestId('count')).toHaveText('1');
});
| 入口点 | 使用 |
|---|---|
@react-native-gpui/testing | launchApp,应用程序驱动程序及其 expect 匹配器。 |
@react-native-gpui/testing/vitest-preset | 测试组件单元测试的预设。 |
@react-native-gpui/testing/vitest-preset-e2e | 测试端到端测试的预设。 |
文档
许可证
麻省理工学院。看到 许可证.