Page 1 of 4 123 ... LastLast
Results 1 to 10 of 37

Thread: Sencha Cmd support for Jasmine tests

  1. #1
    Sencha User
    Join Date
    Apr 2014
    Posts
    3

    Default Sencha Cmd support for Jasmine tests

    Hi,

    I was looking at some of the samples distributed with ExtJS 5 and I saw that some of them actually have 'test' folder, with jasmine tests inside.

    For some time, I was trying to get Jasmine tests to run for Sencha Cmd packages and applications inside Maven. I didn't find anything, which was readily available for such setup (even for simple non-Maven one), so I've decided to roll out my own. I get it working, but I was surprised to see that it seems that there is support testing, builtin in Sencha Cmd and it's not documented anywhere. Questions:

    - Is this a ready to use feature, which I couldn't find any information about?
    - How can I use this feature today (Sencha Cmd 5.0.0.160)
    - Does this feature supports something similar to what karma-runner has - on each save it runs the tests automatically and you can open a browser to run the tests and debug them?

    Thanks

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,450

    Default

    We will be having information about testing in the near future. It's something we are trying to make easier but we are not ready to fully publicize yet.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium Member
    Join Date
    Apr 2012
    Posts
    37

    Default

    Could you give us some hints about the coming solution?

  4. #4
    Sencha Premium Member
    Join Date
    Aug 2014
    Posts
    1

    Default

    I'm also very interested. When can we expect the new solution?

  5. #5
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,296

    Default

    Any progress on this?

  6. #6
    Sencha Premium User SebTardif's Avatar
    Join Date
    Feb 2011
    Location
    Cambridge, MA
    Posts
    1,296

    Default

    Well, as long Sencha Cmd is not supporting full lifecycle, like testing, and support SCM better, we will still need a DevOPS.

    Below is the Maven very simple pom.xml I'm using. It does the following:
    - Run Sencha Cmd
    - Run Jasmine
    - Zip and publish to Nexus repo

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    	<modelVersion>4.0.0</modelVersion>
    	<groupId>com.xyz.open</groupId>
    	<artifactId>sc</artifactId>
    	<version>0.1-SNAPSHOT</version>
    	<packaging>pom</packaging>
    	<description>Xyz Platform Static Content</description>
    	<properties>
    		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    		<sencha.env>production</sencha.env>
    		<zip.full.file.path>${project.build.directory}/MyApp.zip</zip.full.file.path>
    	</properties>
    	<build>
    		<resources>
    			<resource>
    				<directory>.</directory>
    				<includes>
    					<include>app</include>
    					<include>Web.config</include>
    					<include>ext</include>
    					<include>packages</include>
    				</includes>
    				<excludes>
    					<exclude>**/*</exclude>
    				</excludes>
    			</resource>
    		</resources>
    		<plugins>
    			<plugin>
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>exec-maven-plugin</artifactId>
    				<version>1.3.2</version>
    				<executions>
    					<execution>
    						<id>sencha-compile</id>
    						<phase>package</phase>
    						<goals>
    							<goal>exec</goal>
    						</goals>
    						<configuration>
    							<workingDirectory>app</workingDirectory>
    							<!-- Set path to your Sencha Cmd executable -->
    							<executable>sencha</executable>
    							<arguments>
    								<argument>app</argument>
    								<argument>build</argument>
    								<argument>--clean</argument>
    								<argument>--environment</argument>
    								<argument>${sencha.env}</argument>
    							</arguments>
    						</configuration>
    					</execution>
    				</executions>
    			</plugin>
    			<plugin>
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>truezip-maven-plugin</artifactId>
    				<version>1.2</version>
    				<executions>
    					<execution>
    						<id>create-zip</id>
    						<phase>package</phase>
    						<goals>
    							<goal>copy</goal>
    						</goals>
    
    
    						<configuration>
    							<filesets>
    								<fileset>
    									<directory>build/${sencha.env}/MyApp</directory>
    									<excludes>
    										<exclude>**/Readme.md</exclude>
    									</excludes>
    									<outputDirectory>${zip.full.file.path}</outputDirectory>
    								</fileset>
    								<fileset>
    									<directory>.</directory>
    									<includes>
    										<include>Web.config</include>
    									</includes>
    									<outputDirectory>${zip.full.file.path}</outputDirectory>
    								</fileset>
    
    
    							</filesets>
    
    
    						</configuration>
    
    
    					</execution>
    				</executions>
    			</plugin>
    			<plugin>
    				<groupId>org.codehaus.mojo</groupId>
    				<artifactId>build-helper-maven-plugin</artifactId>
    				<version>1.9.1</version>
    				<executions>
    					<execution>
    						<phase>package</phase>
    						<goals>
    							<goal>attach-artifact</goal>
    						</goals>
    
    
    						<configuration>
    							<artifacts>
    								<artifact>
    									<file>${zip.full.file.path}</file>
    									<type>zip</type>
    								</artifact>
    							</artifacts>
    						</configuration>
    					</execution>
    				</executions>
    			</plugin>
    
    
    			<plugin>
    				<groupId>com.github.klieber</groupId>
    				<artifactId>phantomjs-maven-plugin</artifactId>
    				<version>0.4</version>
    				<executions>
    					<execution>
    						<goals>
    							<goal>install</goal>
    						</goals>
    					</execution>
    				</executions>
    				<configuration>
    					<version>1.9.2</version>
    				</configuration>
    			</plugin>
    			<plugin>
    				<groupId>com.github.searls</groupId>
    				<artifactId>jasmine-maven-plugin</artifactId>
    				<version>1.3.1.5</version>
    				<executions>
    					<execution>
    						<goals>
    							<goal>test</goal>
    						</goals>
    						<configuration>
    							<webDriverClassName>org.openqa.selenium.phantomjs.PhantomJSDriver</webDriverClassName>
    							<webDriverCapabilities>
    								<capability>
    									<name>phantomjs.binary.path</name>
    									<value>${phantomjs.binary}</value>
    								</capability>
    							</webDriverCapabilities>
    						</configuration>
    					</execution>
    				</executions>
    				<configuration>
    					<preloadSources>
    						<source>ext/ext-debug.js</source>
    					</preloadSources>
    					<customRunnerTemplate>${project.basedir}/src/test/resources/SpecRunner.html</customRunnerTemplate>
    				</configuration>
    			</plugin>
    
    
    		</plugins>
    		<pluginManagement>
    			<plugins>
    				<!--This plugin's configuration is used to store Eclipse m2e settings 
    					only. It has no influence on the Maven build itself. -->
    				<plugin>
    					<groupId>org.eclipse.m2e</groupId>
    					<artifactId>lifecycle-mapping</artifactId>
    					<version>1.0.0</version>
    					<configuration>
    						<lifecycleMappingMetadata>
    							<pluginExecutions>
    								<pluginExecution>
    									<pluginExecutionFilter>
    										<groupId>
    											org.codehaus.mojo
    										</groupId>
    										<artifactId>
    											exec-maven-plugin
    										</artifactId>
    										<versionRange>
    											[1.3.2,)
    										</versionRange>
    										<goals>
    											<goal>exec</goal>
    										</goals>
    									</pluginExecutionFilter>
    									<action>
    										<ignore></ignore>
    									</action>
    								</pluginExecution>
    							</pluginExecutions>
    						</lifecycleMappingMetadata>
    					</configuration>
    				</plugin>
    			</plugins>
    		</pluginManagement>
    	</build>
    	<dependencies>
    
    
    	</dependencies>
    
    
    	<repositories>
    		<repository>
    			<id>xyz-snapshots</id>
    			<url>http://nexus.dev.xyz.lan/nexus/content/groups/public/</url>
    			<snapshots>
    				<enabled>true</enabled>
    				<updatePolicy>always</updatePolicy>
    			</snapshots>
    		</repository>
    		<repository>
    			<id>xyz</id>
    			<url>http://nexus.dev.xyz.lan/nexus/content/groups/public/</url>
    			<snapshots>
    				<enabled>false</enabled>
    			</snapshots>
    		</repository>
    	</repositories>
    
    
    	<pluginRepositories>
    		<pluginRepository>
    			<id>xyz-snapshots</id>
    			<url>http://nexus.dev.xyz.lan/nexus/content/groups/public/</url>
    			<snapshots>
    				<enabled>true</enabled>
    				<updatePolicy>always</updatePolicy>
    			</snapshots>
    		</pluginRepository>
    		<pluginRepository>
    			<id>xyz</id>
    			<url>http://nexus.dev.xyz.lan/nexus/content/groups/public/</url>
    			<snapshots>
    				<enabled>false</enabled>
    			</snapshots>
    		</pluginRepository>
    	</pluginRepositories>
    
    
    	<distributionManagement>
    		<snapshotRepository>
    			<id>xyz-snapshots</id>
    			<url>http://nexus.dev.xyz.lan/nexus/content/repositories/xyz-snapshots/</url>
    		</snapshotRepository>
    		<repository>
    			<id>xyz</id>
    			<url>http://nexus.dev.xyz.lan/nexus/content/repositories/xyz/</url>
    		</repository>
    	</distributionManagement>
    </project>
    This is the spec to put in src/test/resources/SpecRunner.html
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=$sourceEncoding$">
    $if(autoRefresh)$
    <meta http-equiv="refresh" content="$autoRefreshInterval$">
    $endif$
    <title>Jasmine Spec Runner</title>
    <script type="text/javascript">
    	window.onerror = function(msg, url, line) {
    		if (document.head) {
    			var jserror = document.head.getAttribute('jmp_jserror') || '';
    			if (jserror) {
    				jserror += ':!:';
    			}
    			jserror += msg;
    			document.head.setAttribute('jmp_jserror', jserror);
    		}
    	};
    </script>
    $cssDependencies$ $javascriptDependencies$ $preloadScriptTags$ $sourceScriptTags$
    </head>
    <body>
    	<script type="text/javascript">
    		if (window.location.href.indexOf("ManualSpecRunner.html") !== -1) {
    			document.body
    					.appendChild(document
    							.createTextNode("Warning: opening this HTML file directly from the file system is deprecated. You should instead try running `mvn jasmine:bdd` from the command line, and then visit `http://localhost:8234` in your browser. "))
    		}
    
    
    		var executeJasmineSpecs = function() {
    			window.reporter = new jasmine.$reporter$();
    			jasmine.getEnv().addReporter(reporter);
    			if ('$reporter$' == 'HtmlReporter') {
    				jasmine.getEnv().specFilter = function(spec) {
    					return window.reporter.specFilter(spec);
    				};
    			}
    
    
    			//Don't do live updates when running through HTMLUnit
    			if ('$reporter$' == 'JsApiReporter') {
    				jasmine.getEnv().updateInterval = Number.MAX_VALUE;
    			}
    			
    			Ext.each($specsList$,function(name){
    	    		Ext.Loader.loadScript('src/test/javascript/'+name.substr(5));
    	    	});
    			
    			Ext.syncRequire('Ext.app.Application');
    			// Loading different components like controller, model, view..
    			Ext.application({
    			    name: 'MyApp',
    			    appFolder: 'app/app',
    			    controllers: [],
    			    autoCreateViewport: false,
    
    
    			    init : function() {
    			       
    			    },
    
    
    			    // Launch Jasmine test environment
    			    launch: function () {
    			        var jasmineEnv = jasmine.getEnv();
    			        jasmineEnv.updateInterval = 1000;
    			        jasmineEnv.execute();
    			    }
    
    
    			});
    		
    		};
    
    
    		if (window.addEventListener) {
    			addEventListener('DOMContentLoaded', executeJasmineSpecs, false);
    		} else {
    			attachEvent('onload', executeJasmineSpecs);
    		}
    	</script>
    </body>
    </html>
    This will run any spec file found under: src/test/javascript like SimpleSpec.js:
    Code:
    describe('Sanity Check',function(){
    
    
      it('Ext JS is version 5',function() {
        expect(Ext.getVersion().major).toBe(5);
      });
    
    
    });

  7. #7
    Sencha Premium Member
    Join Date
    Sep 2011
    Posts
    135

    Default

    Quote Originally Posted by mitchellsimoens View Post
    We will be having information about testing in the near future. It's something we are trying to make easier but we are not ready to fully publicize yet.
    Any news about that? Would be very nice to have a guideline ...

  8. #8
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,450

    Default

    We decided to pull back and have a much better product on that but it will take a bit longer and be part of a larger announcement as we get closer to SenchaCon.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  9. #9
    Sencha Premium Member
    Join Date
    Sep 2011
    Posts
    135

    Default

    Thank you for your response. SenchaCon is scheduled to be in April 2015... which is a long time from now!

    Currently there is no way described on how to test Ext JS application. Even the Ext JS 5 guide does not even contain the word test.

    Any chance there will be information regarding this before SenchaCon?

  10. #10
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,450

    Default

    We have something big planned that we want to release on or just before SenchaCon.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

Page 1 of 4 123 ... LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •