Google chrome extension skeleton, based on
Main features:
- js-modules via require.js
- angular.js (popup page, options page)
- deploy script (automatically create crx file)
- logging (one central extension log from all content/background pages)
- localStorage-base configuration
- unit-tests (mocha, karma)
- end to end test (TBD, if possible)
/code
/css
/html
/templates
/images
/js
/lib
/angular
/modules
/background
/controllers
/content
/controllers
/util
/tests
/pure-unit
/modules
/specs
In code
directory you will find:
css
- any css files used by the extensionhtml
- any html files used by the extensionhtml/templates
- html Angular templates used for rendering html codeimages
- any graphics used by the extnesionjs
- code javascript files (entry point for background script, content script(s), and popup scriptjs/lib
- third party libraries, see README.md file there for detailsjs/modules
- all extension-specific code in AMD modules (can be organised in sub-directories)js/modules/background
- Angular.js application for background pagesjs/modules/content
- Angular.js application for content pagesjs/util
- common functionality (messaging and templates) for the extensions, written as AMD modules
In tests\pure-unit
directory you will find: test related JavaScript code for mocha-node
modules
- unit test-specific utility and RequireJS configurationspecs
- unit test modules
cd deploy
./makecrx.sh
cp deploy/pkg/chrome-angular-extension-0.0.1.crx to_some_test
The script deploy/makecrx.sh
will create (once) deploy\dummy-chromium.pem
private key for google chrome extension.
Please don't commit it to public if you don't want.
NOTE: We have to plan that end-2-end and unit tests with karma will work ok, but it is not worked now.
Unit-test with mocha/require.js (but without angular) works ok:
- Install mocha-node first:
npm install -g mocha
- In
tests\pure-unit\
directory runrun-tests.sh
(it installs required dependencies first)
- Open chrome
- Go to chrome://extensions/
- Switch ON for checkbox
Developer mode
- Press
Load unpacked extension...
and specify/code
folder
All pages send log to background page, so it is enough to open bg page console logs.
- Open chrome
- Go to chrome://extensions/
- Find
Chrome Angular extension with require.js
- Go to extension's
html/background.html
- Switch to
Console
-
Daniel Prentis
RequireJS In Chrome Extensions
http://prezi.com/rodnyr5awftr/requirejs-in-chrome-extensions/ -
Salsita
Original chrome-skeleton with require.js
https://github.com/salsita/chrome-extension-skeleton -
Fork of Angular Seed but with changes needed for requireJS support.
https://github.com/tnajdek/angular-requirejs-seed -
Mark Tucker
Chrome Extension using AngularJS - Part 1
http://www.youtube.com/watch?v=Bxg-5C3F8qo -
Mark Tucker
Chrome Extension using AngularJS - Part 2: Services
http://www.youtube.com/watch?v=1O6YTz1yU10 -
How to test e2e google chrome extension with karma?
http://stackoverflow.com/questions/17369462/how-to-test-e2e-google-chrome-extension-with-karma