Skip to content

aoto/FE-UnitTest-example

Repository files navigation

前端单元测试/Webpack构建示例

运行示例前请先在命令行运行npm install安装Node模块!

框架/库/工具

运行单测

浏览器端单测

  • 无需编译直接运行的情况

    • 手工测试
      浏览器直接打开browser_test/browser/index.html
    • 运行npm run browser
      自动进行Phantomjs,Chrome,Firefox的测试,并一直启动着测试进程,修改源文件,自动测试。输出覆盖率报告到coverage_browser/Icov-report/index.html
    • 运行npm run browser-once
      进行Phantomjs,Chrome,Firefox的测试。输出覆盖率报告到coverage_browser/Icov-report/index.html
  • 需Webpack做打包编译的情况

    • 浏览器中测试
      运行node test-server.js,浏览器打开http://localhost:3000/test.html
    • Node环境测试
      运行npm test

Node端单测

运行npm test

Node端覆盖率

运行npm run cover,输出覆盖率报告到coverage/Icov-report/index.html

单测Case源码

浏览器端

Node.js

Webpack

未来前端的工程化体系核心

Features

  1. Plugins
  • 插件化体系,灵活
  1. Loaders
  • 支持各种静态资源
  1. Code Splitting
  • 代码分块,按需加载,性能优秀
  1. Development Tools
  • 开发服务器,SourceMap,模块热重载
  1. Performance
  • 异步IO,缓存
  1. Support
  • AMD, CommonJS, ES6
  1. Optimizations
  • 压缩,分块,多入口,hash
  1. Multiple targets
  • Web, WebWorkers, Node

示例

  • 开发模式
    运行node dev-server.js,浏览器打开http://localhost:3000
  • 测试模式
    运行node test-server.js,浏览器打开http://localhost:3000/test.html
  • 生产模式
    运行npm run build,在build目录下会生成bundle.js

About

A example of FE Unit Test & Webpack usage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors