YeoMan(2)TODO Demo - Karma - Local Storage - Deployment
1. Karma Test
Karma is a frameworks, consist of ngScenario and Jasmine.
Run the command to execute the test
>grunt test
Error Messages:
PhantomJS 1.9.7 (Mac OS X) ERROR ReferenceError: Can't find variable: jQuery at /Users/carl/work/winner/winner-seller-console/mytodo/app/bower_components/jquery-ui/ui/jquery-ui.js:315
Solution:
Compare and check the Jquery file in karma.conf.js with the bower components directories, change the configuration as follow:
'app/bower_components/jquery/dist/jquery.js',
Js file to verify the about page, about.js
'use strict';
describe('Controller: AboutCtrl', function () {
// load the controller's module
beforeEach(module('mytodoApp'));
var AboutCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
AboutCtrl = $controller('AboutCtrl', {
$scope: scope
});
}));
it('should attach a list of awesomeThings to the scope', function () {
expect(scope.awesomeThings.length).toBe(3);
});
});
The bugList page test class main.js
'use strict';
describe('Controller: MainCtrl', function () {
// load the controller's module
beforeEach(module('mytodoApp'));
var MainCtrl,
scope;
// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope) {
scope = $rootScope.$new();
MainCtrl = $controller('MainCtrl', {
$scope: scope
});
}));
it('should have no items to start', function () {
expect(scope.todos.length).toBe(0);
});
it('should add items to the list', function () {
scope.todo = 'Test 1';
scope.addTodo();
expect(scope.todos.length).toBe(1);
});
it('should add items to the list', function () {
scope.todo = 'Test 1';
scope.addTodo();
scope.removeTodo(0);
expect(scope.todos.length).toBe(0);
});
});
2. Persistent with Local Storage
>bower install --save angular-local-storage
Run the command grunt serve. We will have the angular-local-storage dependency on index.html.
Add the Local Storage Module in app.js
angular
.module('mytodoApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch',
'ui.sortable',
'LocalStorageModule'
])
.config(['localStorageServiceProvider', function(localStorageServiceProvider){
localStorageServiceProvider.setPrefix('buglist');
}])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
…snip….
}
Change the Main Controller as follow:
angular.module('mytodoApp')
.controller('MainCtrl', function ($scope, localStorageService) {
var todosInStore = localStorageService.get('todos');
$scope.todos = todosInStore && todosInStore.split('\n') || [];
$scope.$watch('todos', function () {
localStorageService.add('todos', $scope.todos.join('\n'));
}, true);
$scope.addTodo = function () {
$scope.todos.push($scope.todo);
$scope.todo = '';
};
$scope.removeTodo = function (index) {
$scope.todos.splice(index, 1); //remove 1 ele begin from index
};
});
Then Open the tool on chrome — [Resources] ——[Local Storage] ——> Key Value
3. Deploy to Production
Release everything to dist directory
>grunt
Preview release
>grunt serve:dist
I have some Error Message if I access the page from FireFox.
Error Message:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.1/$injector/modulerr?p0=app&p1=Error%3A%20%…0(http%3A%2F%2Flocalhost%3A9000%2Fscripts%2Fd3a6bda4.vendor.js%3A1%3A11551) d3a6bda4.vendor.js:1
Solution:
http://stackoverflow.com/questions/20089960/angularjs-1-2-1-injectormodulerr-after-minifying-yet-it-runs-well-before-mini
The problem should bring in by task uglifyjs. So I change the configuration Gruntfile.js
useminPrepare: {
html: '<%= yeoman.app %>/index.html',
options: {
dest: '<%= yeoman.dist %>',
flow: {
html: {
steps: {
//js: ['concat', 'uglifyjs'],
js: ['concat'],
css: ['cssmin']
},
post: {}
}
}
}
},
grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngmin',
'copy:dist',
'cdnify',
'cssmin',
//'uglify',
'filerev',
'usemin',
'htmlmin'
]);
It works.
I redo all the steps, because that I change one machine and reinstall all the software.
References:
http://yeoman.io/codelab/write-unit-tests.html
http://yeoman.io/codelab/local-storage.html
- 浏览: 2552005 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 241MongoDB 2019(3)Security and Aut ... -
Memory Leak in NodeJS
2018-12-20 06:26 736Memory Leak in NodeJS I have d ... -
Remote Desktop Client
2018-12-07 13:19 1200Remote Desktop Client There is ... -
MetaBase UI Console(2)Docker on MySQL
2018-11-29 06:58 944MetaBase UI Console(2)Docker on ... -
AWS Lambda and Serverless Timeout
2018-09-20 01:20 629AWS Lambda and Serverless Timeo ... -
2018 WebSocket(1)Introduction
2018-03-20 01:22 11102018 WebSocket(1)Introduction ... -
2018 TypeScript Update(3)Introduction Basic Grammar
2018-03-08 03:08 6092018 TypeScript Update(3)Introd ... -
2018 TypeScript Update(2)Introduction Basic Grammar - Classes and Functions
2018-03-06 05:32 5572018 TypeScript Update(2)Introd ... -
2018 TypeScript Update(1)Introduction Basic Grammar - Types and Interface
2018-03-03 01:15 6052018 TypeScript Update(1)Introd ... -
Charts and Console(6)Paging
2018-03-01 00:12 586Charts and Console(6)Paging Th ... -
Vue.JS(3)Google Login
2018-02-14 04:53 1317Vue.JS(3)Google Login I just p ... -
Vue.JS(2)Monitor Water Console - ChartJS and Axios
2018-02-14 03:17 726Vue.JS(2)Monitor Water Console ... -
Vue.JS(1)Introduction and Basic Demo
2018-02-08 06:47 615Vue.JS(1)Introduction and Basic ... -
Charts and Console(5)Validation Form
2017-10-03 05:12 811Charts and Console(5)Validation ... -
Charts and Console(4)Display and Enhancement
2017-09-20 05:39 639Charts and Console(4)Display an ... -
Charts and Console(3)Auth and Login
2017-09-13 03:45 667Charts and Console(3)Auth and L ... -
Charts and Console(2)Login and Proxy
2017-08-31 05:39 878Charts and Console(2)Login and ... -
Charts and Console(1)UI Console and RESTful Client
2017-08-29 11:02 771Charts and Console(1)UI Console ... -
Blog Project(2)Express Backend API - istanbul - mocha - bunyan
2017-06-09 00:05 485Blog Project(2)Express Backend ... -
ReactJS(5)Composition vs Inheritance
2017-06-06 05:55 1117ReactJS(5)Composition vs Inheri ...
相关推荐
generator-karma-esri 生成器,用于配置以对应用程序运行单元测试 有关在 ArcGIS API for JavaScript 应用程序中使用 Karma 运行单元测试的更多信息,请参阅。 入门 安装 [Yeoman](如果您还没有) npm install -g...
RequireJS Yeoman 生成器的生成器。入门确保你已经安装了 : npm install -g yo 安装生成器: npm install -g generator-requirejs-jasmine-karma (本地也可以) 运行: yo requirejs-jasmine-karma:app执照
#yeoman-gradle-plugin 用于将 yeoman 构建集成到您的 gradle 构建中 - 受启发。 查看 [yeoman-gradle-plugin-example] 说明:查看 [yeoman-gradle-plugin-example]。 执行 gradle jettyEclipseRun 如果它坏了,请...
generator-nemo 是一个增加 Nemo 自动化解决方案到浏览器测试工具 Kraken 中的 Yeoman 生成器 标签:generator 分享 window._bd_share_config = { ...
【前端开源库-yeoman-handlebars-engine】是一个用于前端开发的开源工具,它结合了Yeoman生成器和Handlebars模板引擎。Yeoman是构建现代Web应用程序的自动化工具,它可以帮助开发者快速搭建项目结构,自动执行常见...
关于 yeoman 的最佳知识库在他们的网站上: generator 快速安装yeoman 如果你没有 npm 然后去: 安装 npm sudo npm install npm -g 安装 yeoman npm install -g yo Yeoman 生成器前端样板 要运行“ generator-...
my-angular-gulp-seed 由 yeoman generator-gulp-angular 生成,加上我的自定义代码或 fixxes // gryfonn-gulp标记的自定义gulp代码使用 + WATCH 任务减少预处理器任务构建任务包含较少的任务作为依赖注入任务也包含...
无自耕农yeoman 从 sass 移植到
`yeoman-generator-atticus-js` 是一个专为JavaScript项目设计的Yeoman生成器。 Yeoman是一个开发工具,它帮助开发者快速设置新项目的结构,通过自定义的生成器来自动化创建文件和目录的过程,从而提高开发效率。这...
`React Generator Material React`是一个基于Yeoman工具的脚手架,旨在加速React应用程序的开发流程。这个项目为开发者提供了一个预配置的模板,包含了Material Design组件库,使得创建具有现代化用户界面的React...
它基于出色的 Yeoman angular-fullstack 项目。开始在早期阶段注意这个项目 - 所以请在开始之前阅读以下几点! npm installbower installgrunt serve依赖关系如果你还没有它,你将需要 Sass: gem install sass 您...
在创建自动化以运行yeoman而无需用户交互时使用分期付款npm install yeoman-automation-adapter用法const yeoman = require ( 'yeoman-environment' ) ;const { AutoAdapter } = require ( 'yeoman-automation-...
要从 npm 安装 generator-fast-setup,请运行: git clone git@github.com:upro/edouard-yeoman.gitcd Yeoman-Symfony-Project-Setupsudo npm link 最后,启动生成器: yo fast-setup它能做什么适合我们在办公室的...
##安装在命令行中,导航到文件夹: cd ~/.oh-my-zsh/custom/plugins/将存储yeoman到一个名为yeoman的新文件夹中: git clone https://github.com/sayanee/yeoman-oh-my-zsh.git yeoman将yeoman插件与其他插件一起...
发电机-gulp-symfony2 生成器 更改日志: 1.0.5: 支持少。 允许选择“gulp-sass”、“gulp-less”或“gulp-compass”。 生成后运行bundle install (如果使用捆绑)。 1.0.4: 支持通过 'app/config/...
如何安装: git clone git@github.com:iamntz/yeoman-carbon-field-generator.git carbon-field-generatorcd carbon-field-generatornpm installnpm link如何使用它运行yo carbon-field并回答问题。 之后,运行npm ...
否则,如果您想使用 Yeoman Generator 从头开始构建新的均值种子,请按照以下步骤操作。 机器(全局/程序)安装(如果您还没有安装) 安装 git、nodejs、mongodb、phantomjs sudo npm install -g grunt-cli ...
基于基于 Spring webservice Yeoman 的生成器安装安装需要的包( ) npm install --global yo bower grunt-cli安装 jaxrs 生成器(参见 ) 转到 jaxrs-generator 文件夹并运行 npm link运行 jaxrs 生成器生成应用...
发电机-yeoman-样板-es6 用Babel和Gulp用ES6编写的Yeoman发电机样板安装$ git clone https://github.com/FountainJS/generator-yeoman-boilerplate-es6.git$ cd generator-yeoman-boilerplate-es6$ npm link$ yo ...
发电机-风琴测试行程 发电机 ... 要从npm安装generator-yeoman-test-trip,请运行: npm install -g generator-yeoman-test-trip 最后,启动生成器: yo yeoman-test-trip 认识约曼 约曼有一颗金子