gpt4 book ai didi

javascript - Jasmine jQuery 测试鼠标回车

转载 作者:行者123 更新时间:2023-11-28 05:41:25 24 4
gpt4 key购买 nike

我是 jasmine 和 jquery/javascript 的新手,所以我不确定我在这里做错了什么。你能帮我么?。

似乎找不到 DOM 元素,无法正确执行预期的操作。

describe('ClickFunctions', function () {

beforeEach(function () {
jasmine.getFixtures().fixturesPath = 'src/test/js/fixtures';
loadFixtures('Click.html');
});

it('should change the css on mouseenter of step-header',function () {

var step = $('#Step_1');

step.trigger('mouseenter');

expect(step).toHaveCss({
'background-color': '#D9EDF7'
})

});
});

最佳答案

您可能还需要加载您的样式。例如:

loadStyleFixtures('css/stylesheet.css');

并通过控制台日志查看 $('#Step_1') 是否存在。如果没有,那么您的装置 Click.hml 中可能没有必要的元素。如果没有更多信息,很难说。

以下是我找到的资源以及相关示例:

http://www.htmlgoodies.com/beyond/javascript/js-ref/testing-dom-events-using-jquery-and-jasmine-2.0.html

http://www.itsmycodeblog.com/jasmine-jquery-testing-css/

关于javascript - Jasmine jQuery 测试鼠标回车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38892705/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com