This package provides a Karma plugin for Ext JS applications.
npm install karma-extjs-6bash
npm install karma --save-dev
`
Installation
Due to a conflict, the npm package name is karma-extjs-6.
`bash
npm install karma-extjs-6 --save-dev
`
Configuration
See the test application in the test directory for an example.
$3
See the Karma configuration documentation to create a configuration for Karma, and include extjs-6 as a framework. By default, test execution will automatically start when the application launches.
#### Ext JS 4 - Latest
When using the Microloader, the manifest and scripts should not be embedded in the index.html file.
1. If the application defines an Ext.app.Application.launch method, ensure it calls its parent.
2. Copy the before load manifest configuration into a script file (e.g. app/extras/manifest.js).
3. The manifest is not embedded by default. If the manifest is embedded, set the embed configuration to false in the app.json file.
3. Set the microloader embed configuration to false in the app.json file.
`json
"output": {
"microloader": {
"embed": false
}
}
`
4. When testing a production build, set production to true.
5. Configure file patterns for all of the application, build, and package resources.
6. Configure a proxy for the toolkit manifest.
7. Configure proxies for the application source directories.
8. Configure browserNoActivityTimeout to account for the amount of time the application takes to load. Larger applications and development builds require more time.
`js
module.exports = function (config) {
config.set({
...
frameworks: ['jasmine', 'extjs-6'],
...
files: [
...
'app/extras/manifest.js',
'{build,classic,packages}/*/.css'
],
...
extJs: {
production: true
},
...
proxies: {
'/classic/', '/base/classic/',
'/classic.json': '/base/classic.json'
},
...
browserNoActivityTimeout: 20000
});
};
`
#### Ext JS 3
Test Ext JS 3 applications with the onReady option. Test execution will start when the document and framework are ready.
`js
module.exports = function (config) {
config.set({
...
frameworks: ['jasmine', 'extjs-6'],
...
extJs: {
onReady: true
}
});
};
`
#### Custom
To start test execution at a distinct time disable autoStart, and call karma.loaded.
`js
module.exports = function (config) {
config.set({
...
frameworks: ['jasmine', 'extjs-6'],
...
extJs: {
autoStart: false
}
...
});
};
`
`js
...
afterRenderHandler: function (viewport, eOpts) {
if (window.karma) {
window.karma.loaded();
}
},
...
`
$3
#### Microloader
The Microloader can be also be used for unit testing. The application can be disabled to prevent conflicts between instances of a class. Classes can be loaded using Ext.require.
1. Follow the steps for configuring Karma for integration testing.
2. Set autoLaunch to false.
3. Set onReady to true.
`js
extJs: {
autoLaunch: false,
onReady: true
}
`
`js
describe('Fiddle.mixin.Test', {
beforeAll(function (done) {
Ext.require('Fiddle.mixin.Test', function () {
done();
});
});
it('is defined', function () {
expect(Fiddle.mixin.Test).toBeDefined();
});
...
``