PlayWright
https://playwright.dev/
安裝
npm i @playwright/test範例
import React, { useState } from 'react';
import './App.css';
function App() {
const [inputValue, setInputValue] = useState('');
const [submittedText, setSubmittedText] = useState('');
const handleInputChange = (e) => {
setInputValue(e.target.value);
};
const handleSubmit = () => {
setSubmittedText(inputValue);
setInputValue(''); // Clear the input field after submit
};
return (
<div>
<h1>Sample React Component</h1>
<input
type="text"
placeholder="Enter some text"
value={inputValue}
onChange={handleInputChange}
/>
<button onClick={handleSubmit}>Submit</button>
{submittedText && <p>Submitted Text: {submittedText}</p>}
</div>
);
}
export default App;使用 Headed 模式
開啟錄製功能產生測試代碼

產生 Trace

HTML 測試報告

使用內建 VS Code 工具
Last updated

