是否有使用Jasmine或其他任何测试框架的ExtJs框架的良好示例?我正在使用ExtJs 6.7和7.1
我在Sencha论坛上找到了该主题,但我认为该主题已过时,该主题似乎已死。https://www.sencha.com/forum/showthread.php?308318
我在siesta-lite(https://www.npmjs.com/package/siesta-lite)上取得了一些成功,但是我正在寻找一种免费的替代方法,可以在CI流程中运行它。
谢谢!
这是运行此命令时生成的我的目录结构
sencha -sdk <path-to-ext-framework> generate app MyApp ./extjs-jasmine
extjs-jasmine/
...
app/
store/
...
Personnel.js
...
...
index.html
...
test.html
test/
lib/
jasmine-3.5.0/ (just download and extract latest jasmine here)
app-test.js
spec/
store/
TestPersonnelStore.js
这里是test.html
<!DOCTYPE HTML>
<html manifest="">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Jasmine Unit Tests</title>
<link rel="stylesheet" href="test/lib/jasmine-3.5.0/jasmine.css">
<script src="ext/ext-bootstrap.js"></script>
<script src="test/lib/jasmine-3.5.0/jasmine.js"></script>
<script src="test/lib/jasmine-3.5.0/jasmine-html.js"></script>
<script src="test/lib/jasmine-3.5.0/boot.js"></script>
<script src="test/lib/app-test.js"></script>
<script src="test/spec/store/TestPersonnelStore.js"></script>
</head>
<body>
</body>
</html>
这里是test / lib / app-test.js
Ext.Loader.setConfig({
enabled: true,
disableCaching: false,
paths: {
'Ext.ux': 'ext/packages/ux/src',
'Ext.chart': 'ext/packages/charts/src/chart',
'Ext.chart.legend.LegendBase': 'ext/packages/charts/classic/src/chart/legend/LegendBase.js',
'Ext.chart.theme.BaseTheme': 'ext/packages/charts/classic/src/chart/theme/BaseTheme.js',
'Ext.draw': 'ext/packages/charts/src/draw',
'Ext.draw.ContainerBase': 'ext/packages/charts/classic/src/draw/ContainerBase.js',
'Ext.draw.SurfaceBase': 'ext/packages/charts/classic/src/draw/SurfaceBase.js',
'MyApp.spec': 'test/spec',
}
});
Ext.application({
name: 'MyApp',
autoCreateViewport: false
});
这里是app / store / Personnel.js
Ext.define('MyApp.store.Personnel', {
extend: 'Ext.data.Store',
alias: 'store.personnel',
fields: [
'name', 'email', 'phone'
],
data: { items: [
{ name: 'Jean Luc', email: "[email protected]", phone: "555-111-1111" },
{ name: 'Worf', email: "[email protected]", phone: "555-222-2222" },
{ name: 'Deanna', email: "[email protected]", phone: "555-333-3333" },
{ name: 'Data', email: "[email protected]", phone: "555-444-4444" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'items'
}
}
});
这里是test / spec / store / TestPersonnelStore.js
describe('MyApp.spec.store.TestPersonnelStore', () => {
beforeAll((done) => {
Ext.require([
'MyApp.store.Personnel'
], () => {
done();
});
});
it('should load data...', (done) => {
const store = Ext.create('MyApp.store.Personnel', {
autoLoad: true
});
expect(store.getCount()).toBe(4);
done();
});
});
然后将浏览器指向http://<host>:<port>/<context>/test.html