当我尝试使用 jasmine 进行测试时,应用程序文件夹未加载到 Ext.appliation
App folder is not loading in Ext.appliation when i try to test using jasmine
我正在尝试在我的应用程序 (Ext js 5) 中实施 jasmine 以进行单元测试。为此,我创建了应用程序测试文件。
Ext.require('Ext.app.Application');Ext.Loader.setConfig({enabled:true});
Ext.onReady(function() {
var Application = Ext.create('Ext.app.Application', {
name: 'epmct',
appFolder:'app',
launch: function() {
Ext.create('epmct.view.vpp.dashboard.VppDashboardMainPage');
}
});
});
当我 运行 应用程序通过 specrunner.html(开始单元测试的文件)时出现错误
Uncaught Error: [Ext.Loader] Some requested files failed to load.
我尝试使用 Ext.Loader.setPath('epmct','app'); 设置路径还是不行。
请找到我的 specrunner.html 文件代码
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.3.2</title>
<link rel="shortcut icon" type="image/png" href="test/jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="test/jasmine/jasmine.css">
<script type="text/javascript" src="test/jasmine/jasmine.js"></script>
<script type="text/javascript" src="test/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="test/jasmine/boot.js"></script>
<!-- include Ext Js files and Css... -->
<script src="ext/ext-all.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="app-test.js"></script>
<script type="text/javascript" src="test/spec/DashboardSpec.js"></script>
</head>
<body>
</body>
</html>
我将指导您使用 Sencha Cmd 5.、ExtJs 5. 完成快速设置和工作测试,并希望您仅需使用 Sencha 工作区8步.
首先使用 Sencha Cmd
创建一个新工作区。如果您已经有一个工作区,则可以跳过此步骤。
sencha generate workspace \path\to\the\folder
使用 Sencha Cmd
创建一个新的 ExtJs
应用。
cd \path\to\the\workspace
sencha -sdk \path\to\the\sdk generate app Jasmine jasmine
然后在应用程序文件夹中创建一个名为 app-test
的新文件夹。
- 下载单机版Jasmine
- 解压缩并将
lib
文件夹复制到您之前创建的 app-test
文件夹中。
- 创建一个 html 文件
index-test.html
并将其放在您的应用程序文件夹中:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Test</title>
<link rel="shortcut icon" type="image/png" href="app-test/lib/jasmine-2.3.4/jasmine_favicon.png">
<link rel="stylesheet" href="app-test/lib/jasmine-2.3.4/jasmine.css">
<script src="app-test/lib/jasmine-2.3.4/jasmine.js"></script>
<script src="app-test/lib/jasmine-2.3.4/jasmine-html.js"></script>
<script src="app-test/lib/jasmine-2.3.4/boot.js"></script>
<!-- include source files here... -->
<script src="../ext/build/ext-all-debug.js"></script>
<!-- include spec files here... -->
<script src="app-test.js"></script>
</head>
<body>
<div id="test"></div>
</body>
</html>
- 创建一个 javascript 文件
app-test.js
并将其放在您的应用程序文件夹中:
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'Jasmine',
extend: 'Jasmine.Application',
autoCreateViewport: false
});
describe('Jasmine.view.main.Main', function() {
//reusable scoped variable
var mainView = null;
// setup / teardown
beforeEach(function() {
// create a fresh main view for every test to avoid test pollution
mainView = Ext.create('Jasmine.view.main.Main'/*, {
renderTo : 'test' //see index-test.html to see where this is defined
}*/);
});
afterEach(function() {
// destroy the main view after every test so we don't pollute the environment
mainView.destroy();
});
it('should inherit from Ext.container.Container', function() {
expect(mainView.isXType('container')).toEqual(true);
});
it('should be configured as a border layout', function() {
expect(mainView.getLayout().type).toEqual('border');
});
});
- 在浏览器中打开 index-test.html 并查看结果
额外资源:
http://www.ladysign-apps.com/developer/setup-jasmine-tdd-with-for-ext-js/
https://www.sencha.com/blog/automating-unit-tests/
https://github.com/SenchaProSvcs/UnitTestDemo
http://docs.sencha.com/extjs/4.2.0/#!/guide/testing
http://docs.sencha.com/extjs/4.2.0/#!/guide/testing_controllers
https://jasmine.github.io/2.3/introduction.html
我正在尝试在我的应用程序 (Ext js 5) 中实施 jasmine 以进行单元测试。为此,我创建了应用程序测试文件。
Ext.require('Ext.app.Application');Ext.Loader.setConfig({enabled:true});
Ext.onReady(function() {
var Application = Ext.create('Ext.app.Application', {
name: 'epmct',
appFolder:'app',
launch: function() {
Ext.create('epmct.view.vpp.dashboard.VppDashboardMainPage');
}
});
});
当我 运行 应用程序通过 specrunner.html(开始单元测试的文件)时出现错误
Uncaught Error: [Ext.Loader] Some requested files failed to load.
我尝试使用 Ext.Loader.setPath('epmct','app'); 设置路径还是不行。
请找到我的 specrunner.html 文件代码
<!DOCTYPE html><html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.3.2</title>
<link rel="shortcut icon" type="image/png" href="test/jasmine/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="test/jasmine/jasmine.css">
<script type="text/javascript" src="test/jasmine/jasmine.js"></script>
<script type="text/javascript" src="test/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="test/jasmine/boot.js"></script>
<!-- include Ext Js files and Css... -->
<script src="ext/ext-all.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="app-test.js"></script>
<script type="text/javascript" src="test/spec/DashboardSpec.js"></script>
</head>
<body>
</body>
</html>
我将指导您使用 Sencha Cmd 5.、ExtJs 5. 完成快速设置和工作测试,并希望您仅需使用 Sencha 工作区8步.
首先使用
Sencha Cmd
创建一个新工作区。如果您已经有一个工作区,则可以跳过此步骤。sencha generate workspace \path\to\the\folder
使用
Sencha Cmd
创建一个新的ExtJs
应用。cd \path\to\the\workspace sencha -sdk \path\to\the\sdk generate app Jasmine jasmine
然后在应用程序文件夹中创建一个名为
app-test
的新文件夹。- 下载单机版Jasmine
- 解压缩并将
lib
文件夹复制到您之前创建的app-test
文件夹中。 - 创建一个 html 文件
index-test.html
并将其放在您的应用程序文件夹中:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Test</title>
<link rel="shortcut icon" type="image/png" href="app-test/lib/jasmine-2.3.4/jasmine_favicon.png">
<link rel="stylesheet" href="app-test/lib/jasmine-2.3.4/jasmine.css">
<script src="app-test/lib/jasmine-2.3.4/jasmine.js"></script>
<script src="app-test/lib/jasmine-2.3.4/jasmine-html.js"></script>
<script src="app-test/lib/jasmine-2.3.4/boot.js"></script>
<!-- include source files here... -->
<script src="../ext/build/ext-all-debug.js"></script>
<!-- include spec files here... -->
<script src="app-test.js"></script>
</head>
<body>
<div id="test"></div>
</body>
</html>
- 创建一个 javascript 文件
app-test.js
并将其放在您的应用程序文件夹中:
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'Jasmine',
extend: 'Jasmine.Application',
autoCreateViewport: false
});
describe('Jasmine.view.main.Main', function() {
//reusable scoped variable
var mainView = null;
// setup / teardown
beforeEach(function() {
// create a fresh main view for every test to avoid test pollution
mainView = Ext.create('Jasmine.view.main.Main'/*, {
renderTo : 'test' //see index-test.html to see where this is defined
}*/);
});
afterEach(function() {
// destroy the main view after every test so we don't pollute the environment
mainView.destroy();
});
it('should inherit from Ext.container.Container', function() {
expect(mainView.isXType('container')).toEqual(true);
});
it('should be configured as a border layout', function() {
expect(mainView.getLayout().type).toEqual('border');
});
});
- 在浏览器中打开 index-test.html 并查看结果
额外资源:
http://www.ladysign-apps.com/developer/setup-jasmine-tdd-with-for-ext-js/
https://www.sencha.com/blog/automating-unit-tests/
https://github.com/SenchaProSvcs/UnitTestDemo
http://docs.sencha.com/extjs/4.2.0/#!/guide/testing
http://docs.sencha.com/extjs/4.2.0/#!/guide/testing_controllers
https://jasmine.github.io/2.3/introduction.html