带有组件测试的固定装置
执行柏树组件测试,我将固定装置加载到钩子之前。
固定装置加载,但在第一次测试后消失。
before(() => {
cy.fixture('my-fixture').as('fixture')
})
it('test1', function() {
mount(component, {
propsData: {'data': this.fixture},
})
})
it('test2', function() {
mount(component, {
propsData: {'data': this.fixture}, // undefined
})
})
如何修复固定装置?
Performing a Cypress component test, I load a fixture in a before hook.
The fixture loads, but disappears after the first test.
before(() => {
cy.fixture('my-fixture').as('fixture')
})
it('test1', function() {
mount(component, {
propsData: {'data': this.fixture},
})
})
it('test2', function() {
mount(component, {
propsData: {'data': this.fixture}, // undefined
})
})
How do I fix the fixture?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在测试之间清除了Alises。您可以将钩子更改为
tofEreach()
,以允许所有测试查看数据。请注意,每次称为磁盘时,都不会从磁盘中读取固定装置,
cy.fixture()
命令具有一个缓存。Alises are cleared down between tests. You can change the hook to
beforeEach()
to allow all tests to see the data.Note that the fixture is not read from disk every time it's called, the
cy.fixture()
command has a cache the returns the previously read value on 2nd, 3rd calls.