我不明白为什么只有当我在 <body>
中设置 beforeEach
时我的测试才能通过?
我想更改每个 <body>
中的 it
但它不起作用。
有什么想法吗?
// ❌ Not working
describe('#nestedForm', () => {
it('should create new todo', () => {
startStimulus()
document.body.innerHTML = `<form data-controller="nested-form"></form>`
// ...
})
})
// ✅ Working
describe('#nestedForm', () => {
beforeEach(() => {
startStimulus()
document.body.innerHTML = `<form data-controller="nested-form"></form>`
})
it('should create new todo', () => {
// ...
})
})