From ac304611d121cfc1d33137f3267fa1d4d96d525d Mon Sep 17 00:00:00 2001 From: cesine Date: Sat, 27 Oct 2012 19:13:55 -0400 Subject: [PATCH 1/2] adding manifest and ng-csp to run in chrome extension --- app/index.html | 2 +- app/manifest.json | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/manifest.json diff --git a/app/index.html b/app/index.html index 4d4b84990b..12d5dd364e 100644 --- a/app/index.html +++ b/app/index.html @@ -1,5 +1,5 @@ - + My AngularJS App diff --git a/app/manifest.json b/app/manifest.json new file mode 100644 index 0000000000..2b4c5597ed --- /dev/null +++ b/app/manifest.json @@ -0,0 +1,19 @@ +{ + "name": "Angular Seed - In Chrome Extensions", + "version": "1.1", + "description": "To debug and run Angular seed without a server", + + "app": { + "launch": { + "local_path": "index.html" + } + }, + "offline_enabled": true, + "permissions": [ + "unlimitedStorage" + ], + "icons": { + }, + "manifest_version" : 2, + "content_security_policy" : "default-src 'self'; " +} \ No newline at end of file From 785c058ecdff01cf79150de545c3b391845a8864 Mon Sep 17 00:00:00 2001 From: cesine Date: Tue, 30 Apr 2013 17:27:16 -0400 Subject: [PATCH 2/2] bringing in a requirejs e2e tests based off of the karma examples in https://github.com/karma-runner/karma/tree/master/test/e2e/requirejs --- config/karma-e2e.conf.js | 64 +++++++++++++++++++---- scripts/e2e-test.sh | 2 +- test/e2e/dependency.js | 7 +++ test/e2e/main.js | 26 ++++++++++ test/e2e/runner.html | 11 ---- test/e2e/scenarios.js | 107 +++++++++++++++++++++++---------------- test/e2e/shim.js | 2 + 7 files changed, 153 insertions(+), 66 deletions(-) create mode 100644 test/e2e/dependency.js create mode 100644 test/e2e/main.js delete mode 100644 test/e2e/runner.html create mode 100644 test/e2e/shim.js diff --git a/config/karma-e2e.conf.js b/config/karma-e2e.conf.js index 51f51d2ee3..d6becd4af9 100644 --- a/config/karma-e2e.conf.js +++ b/config/karma-e2e.conf.js @@ -1,22 +1,64 @@ basePath = '../'; -files = [ - ANGULAR_SCENARIO, - ANGULAR_SCENARIO_ADAPTER, - 'test/e2e/**/*.js' -]; +// Karma configuration +// modified by a human based on angular-seed config Generated on Thu Jul 26 2012 14:35:23 GMT-0700 (PDT) -autoWatch = false; +// base path, that will be used to resolve files and exclude -browsers = ['Chrome']; +// list of files / patterns to load in the browser +files = [ ANGULAR_SCENARIO, + ANGULAR_SCENARIO_ADAPTER, REQUIRE, REQUIRE_ADAPTER, + 'test/e2e/main.js', -singleRun = true; + // all the sources, tests + { + pattern : 'test/e2e/*.js', + included : false + } ]; + +// test results reporter to use +// possible values: dots || progress +reporter = [ 'progress' ]; + +// web server port +port = 9876; + +// cli runner port +runnerPort = 9100; + +// enable / disable colors in the output (reporters and logs) +colors = true; + +// level of logging +// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || +// LOG_DEBUG +logLevel = LOG_INFO; + +// enable / disable watching file and executing tests whenever any file +// changes +autoWatch = true; + +// Start these browsers, currently available: +// - Chrome +// - ChromeCanary +// - Firefox +// - Opera +// - Safari +// - PhantomJS +browsers = [ 'ChromeCanary' ]; + +// If browser does not capture in given timeout [ms], kill it +captureTimeout = 60000; + +// Continuous Integration mode +// if true, it capture browsers, run tests and exit +singleRun = false; proxies = { - '/': 'http://localhost:8000/' + '/' : 'http://localhost:8000/' }; junitReporter = { - outputFile: 'test_out/e2e.xml', - suite: 'e2e' + outputFile : 'test_out/e2e.xml', + suite : 'e2e' }; diff --git a/scripts/e2e-test.sh b/scripts/e2e-test.sh index 5d8a335e69..616f8c99a7 100755 --- a/scripts/e2e-test.sh +++ b/scripts/e2e-test.sh @@ -6,4 +6,4 @@ echo "" echo "Starting Karma Server (http://karma-runner.github.io)" echo "-------------------------------------------------------------------" -karma start $BASE_DIR/../config/karma-e2e.conf.js $* +$BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma-e2e.conf.js $* diff --git a/test/e2e/dependency.js b/test/e2e/dependency.js new file mode 100644 index 0000000000..f4cdd0f32b --- /dev/null +++ b/test/e2e/dependency.js @@ -0,0 +1,7 @@ +define(function() { + // return the module value + return function (a, b) { + return a + b; + }; + } +); diff --git a/test/e2e/main.js b/test/e2e/main.js new file mode 100644 index 0000000000..a51f9c5662 --- /dev/null +++ b/test/e2e/main.js @@ -0,0 +1,26 @@ +var allTestFiles = []; +var TEST_REGEXP = /scenarios\.js$/; + +Object.keys(window.__karma__.files).forEach(function(file) { + if (TEST_REGEXP.test(file)) { + allTestFiles.push(file); + } +}); + +require.config({ + // Karma serves files under /base, which is the basePath from your config file + baseUrl: '', + + // example of using shim, to load non AMD libraries (such as Backbone, jquery) + shim: { + 'test/e2e/shim.js': { + exports: 'global' + } + }, + + // dynamically load all test files + deps: allTestFiles, + + // we have to kick of jasmine, as it is asynchronous + callback: window.__karma__.start +}); diff --git a/test/e2e/runner.html b/test/e2e/runner.html deleted file mode 100644 index 859c90e3d6..0000000000 --- a/test/e2e/runner.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - End2end Test Runner - - - - - - - diff --git a/test/e2e/scenarios.js b/test/e2e/scenarios.js index 26e174a401..8a0ea05383 100644 --- a/test/e2e/scenarios.js +++ b/test/e2e/scenarios.js @@ -1,45 +1,66 @@ 'use strict'; - -/* http://docs.angularjs.org/guide/dev_guide.e2e-testing */ - -describe('my app', function() { - - beforeEach(function() { - browser().navigateTo('../../app/index.html'); - }); - - - it('should automatically redirect to /view1 when location hash/fragment is empty', function() { - expect(browser().location().url()).toBe("/view1"); - }); - - - describe('view1', function() { - - beforeEach(function() { - browser().navigateTo('#/view1'); - }); - - - it('should render view1 when user navigates to /view1', function() { - expect(element('[ng-view] p:first').text()). - toMatch(/partial for view 1/); - }); - - }); - - - describe('view2', function() { - - beforeEach(function() { - browser().navigateTo('#/view2'); +define( + [ 'test/e2e/dependency', 'test/e2e/shim' ], + function(seeifrequirecanbeusedtoloadadependancy) { + + /* Jasmine tests dont run in scenarios... */ + // describe('Jasmine: sample tests', function() { + // it('should pass', function() { + // console.log("im in a test"); + // expect(true).toBe(true); + // }); + // + // it('should sum', function() { + // $hi = seeifrequirecanbeusedtoloadadependancy(1, 2); + // console.log(hi); + // expect(hi).toBe(3); + // }); + // }); + /* http://docs.angularjs.org/guide/dev_guide.e2e-testing */ + describe( + 'my app', + function() { + + beforeEach(function() { + console.log("before each" + + seeifrequirecanbeusedtoloadadependancy(Date.now(), 3)); + console.log("Hi this variables comes from a shim: " + + globalVarWeDeclared); + browser().navigateTo('app/index.html'); + }); + + it( + 'should automatically redirect to /view1 when location hash/fragment is empty', + function() { + expect(browser().location().url()).toBe("/view1"); + }); + + describe('view1', function() { + + beforeEach(function() { + browser().navigateTo('#/view1'); + }); + + it('should render view1 when user navigates to /view1', + function() { + expect(element('[ng-view] p:first').text()).toMatch( + /partial for view 1/); + }); + + }); + + describe('view2', function() { + + beforeEach(function() { + browser().navigateTo('#/view2'); + }); + + it('should render view2 when user navigates to /view2', + function() { + expect(element('[ng-view] p:first').text()).toMatch( + /partial for view 2/); + }); + + }); + }); }); - - - it('should render view2 when user navigates to /view2', function() { - expect(element('[ng-view] p:first').text()). - toMatch(/partial for view 2/); - }); - - }); -}); diff --git a/test/e2e/shim.js b/test/e2e/shim.js new file mode 100644 index 0000000000..adfd3d6121 --- /dev/null +++ b/test/e2e/shim.js @@ -0,0 +1,2 @@ +console.log("loading a shim"); +window.globalVarWeDeclared = 'some exported value';