[英]jasmine-jquery isn't finding an element in my fixture file
我正在嘗試使用jasmine-jquery進行UI測試。 我將業力用作測試運行程序,將茉莉花用作測試框架。 我認為我已經成功加載了夾具,並且在我的業力配置中列出了jasmine-jquery作為測試框架。
但是我無法使用jasmine-jquery在DOM中找到元素。 為什么?
目錄結構
base
spec
javascripts
fixtures
myfixture.html
karma.conf.js
tests
settingUpHTMLFixtures.test.js
myfixture.html
<div id="my-fixture">foo bar</div>
settingUpHTMLFixtures.test.js
jasmine.getFixtures().fixturesPath = 'base/spec/javascripts/fixtures';
loadFixtures('myfixture.html');
describe('testing out jasmine-jquery', function(){
it('can find an element in the dom using jasmine-jquery', function(){
expect($j('#my-fixture')).toBeInDOM();
})
})
karma.conf.js
const webpackConfig = require('./webpack.config.js');
module.exports = function(config) {
config.set({
basePath: "",
files: ["tests/**/*.test.js", 'spec/javascripts/fixtures/*.html'],
frameworks: ['jasmine-jquery', 'jasmine', 'jasmine-matchers'],
preprocessors: {
"tests/**/*.test.js": ["webpack"]
},
webpack: webpackConfig,
plugins : [
'karma-chrome-launcher',
'karma-jasmine',
'karma-jasmine-jquery',
'karma-jasmine-matchers',
'karma-webpack',
'karma-jasmine-html-reporter'
],
logLevel: config.LOG_INFO,
reporters: ['kjhtml'],
port: 9876,
browsers: ["Chrome"],
//...
});
};
目前,我只是收到一條消息,表明測試失敗,這是在testing out jasmine-jquery can find an element in the dom using jasmine-jquery FAILED Expected jQuery({ context: HTMLNode, selector: '#my-fixture' }) to be in do m. at UserContext.<anonymous> (tests/settingUpHTMLFixtures.test.js:78:31)"
testing out jasmine-jquery can find an element in the dom using jasmine-jquery FAILED Expected jQuery({ context: HTMLNode, selector: '#my-fixture' }) to be in do m. at UserContext.<anonymous> (tests/settingUpHTMLFixtures.test.js:78:31)"
我遇到了路徑錯誤。 自行創建基本目錄是一個錯誤。 業力僅提供基本目錄中的所有內容。
我唯一需要使用單詞base的時候是在設置燈具路徑時(如上面的settingUpHTMLFixtures.test.js代碼所示)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.