App folder is not loading in Ext.appliation when i try to test using jasmine

Surya Prakash Tumma

I am trying to implement jasmine in my application(Ext js 5)for unit testing. For that i have created app-test file.

  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');
    }
    });
 });

When i run the application throught specrunner.html(File to start unit testing ) I am getting error

Uncaught Error: [Ext.Loader] Some requested files failed to load.

and I tried to set path using Ext.Loader.setPath('epmct','app'); still it is not working.

Please find my specrunner.html file code

    <!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>
Tarabass

I will guide you through a quick setup with working tests using Sencha Cmd 5., ExtJs 5. and expecting you to use a Sencha workspace in just 8 steps.

  1. First create a new workspace using Sencha Cmd. If you already have a workspace you can skip this step.

    sencha generate workspace \path\to\the\folder

  2. Create a new ExtJs app using Sencha Cmd.

    cd \path\to\the\workspace sencha -sdk \path\to\the\sdk generate app Jasmine jasmine

  3. Then create a new folder called app-test within the app folder.

  4. Download the standalone version of Jasmine
  5. Unzip it and copy the lib folder into the app-test folder you created before.
  6. Create a html file index-test.html and place it in your app folder:

<!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>

  1. Create a javascript file app-test.js and place it in your app folder:

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');
	});
});

  1. Open index-test.html in a browser and see the results

Extra resources:
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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Gcc throws error when I try to compile the test folder in libburn

Error: Invariant failed: You should not use <Link> outside a <Router> when I try to test my app using localhost

How do I unit test if an element is visible when the *ngIf directive is used using Jasmine in Angular

I try to test IOS IN APP sandbox to payment

"A matching symbol file was not found in this folder " . Getting this error when i try to debug using dump file

Error on jest when I try to run the test

AssertionError when I try to write a unit test

How can I fit the test data using min max scaler when I am loading the model?

How to include Ext JS in Jasmine test

I am getting an error when I try to build the production build using the ckeditor5 with angular app

I got error when i try to acces an image folder?

When I try to set a clickListener, app crashes

App crashes when I try to turn on Bluetooth

App crashes when I try to logout

Build Failed when i try to run the app

Android app crashes when i try to reLogin

App crashes when i try to run this page

App crashes when I try to open a Fragment

App crashes when i try to set onClickListener

Jasmine test returns type error when using $httpBackend.flush();

EF Core is lazy loading when I try to eager load with .Include()

App keeps crashing when i try to login in an app i made

Can I write test cases for AngularJS service using Jasmine spy?

How do I unit test downloading a file using Jasmine (Angular)?

How can I test what an AngularJS promise returns using Jasmine?

How do I make IDEA/Android Studio recognize my unit test folder when using Gradle?

Permission denied when I try to cd into any folder

Why is there no "pathspec" when I try to remove a folder in Git?

Loading AngularJS module in Jasmine test via Grunt