This is an ember-cli
addon that makes writing FastBoot tests for your Ember app easy and straightforward!
It works by spinning up a local FastBoot server using ember-cli-fastboot,and then runs your Mocha-based end-to-end tests to assert that your app works as expected in a FastBoot environment.
Note that this is for Ember apps only. For testing addons you can use this related project: ember-fastboot-addon-tests.
ember install ember-fastboot-app-tests
After installing the addon you should find a new folder fastboot-tests
which will hold your test files. The defaultblueprint will have installed a first simple test to start with.
Before we get our hands dirty let's make some important things clear first! Because there are some significant differencesbetween the FastBoot tests that this addon adds support for, and the usual Ember.js tests as you might know them.
The normal Ember.js tests, no matter whether these are unit, integration or acceptance tests, all run in the same browser(a real or a headless one like PhantomJS) and process as the actual code you test. So you can import
any module from yourapp/addon, you have a DOM available (where your integration or acceptance tests render into), you have jQuery and so on.
Contrary to that for your FastBoot tests, your test and the code to test for run in two separate processes. The FastBootserver runs your app, but you can only access that through FastBoot's HTTP server. Your test itself runs in a node.jsenvironment, not a browser! You can send a HTTP GET request to your FastBoot server, and it gives you a response, thatis some HTTP headers and basically a plain string of HTML.
So this is a real end to end test, like the tests you do with tools like Selenium/WebDriver. Your running app is a blackbox, and you have no information about what is happening inside it, except for the HTML it returns. So no import
, nodocument
, no DOM, no jQuery (ok, wait, I might be proven wrong there!).
A test file generated by this addon will look like this:
const expect = require('chai').expect;
describe('index', function() {
it('renders', function() {
return this.visit('/')
.then(function(res) {
let $ = res.jQuery;
let response = res.response;
// add your real tests here
expect(response.statusCode).to.equal(200);
expect($('body').length).to.equal(1);
});
});
});
This Mocha test file defines a simple test that asserts that your app's index route returns the expected HTML that thedefault index.hbs
defines. Although this might seem not worth testing at first sight, your app still can easily breakthat, e.g. by importing some external JavaScript that can only run on a browser or accessing the DOM in a component fromwithin init
.
You may wonder here where all the necessary bootstrap code is, for building the app and spinning up the FastBoot server. Thegood news is, you do not have to care about this, this addon takes care of this for you! All the setup and tear down code isadded to your test suite in some before
and after
Mocha hooks.
But you still may have stumbled upon the use of jQuery in the above test, although a chapter before it was said that you have noDOM and no jQuery available to your tests. This is where the visit
helper comes into play...
This addon gives you a visit
helper that makes testing pretty easy. You give it a route of your app (as you would do itwith the visit
helper in an acceptance test) to make a request to. It then makes a HTTP request to your FastBoot serverfor that route, and returns a Promise
. If the request was successfull, it resolves with aresponse object, which is a POJO with the following properties:
response
: the node.js response (an instance of http.IncomingMessage).You can use that e.g. to check the HTTP headers received by accessing response.headers
.jQuery
: although the tests run in node-land and have no real DOM available, with the help of jsdom - a JavaScript implementation of the DOM standard - akind of faked DOM is available that jQuery can operate upon. So you can express your DOM assertions in a way you are used to from normal Ember tests.Besides the already generated test file for you index
route, adding a new route is easy:
ember g fastboot-test foo
This will add a foo-test.js
file with the boilerplate for your new test.
ember fastboot:test
This will run all your FastBoot tests.
To make this addon useful for as many users as possible, please contribute, by giving some feedback, submitting issues or pull requests!
1.Fastboot简介 Fastboot是Android快速升级的一种方法,Fastboot的协议fastboot_protocol.txt在源码目录./bootable/bootloader/legacy下可以找到。 Fastboot客户端是作为Android系统编译的一部分,编译后位于./out/host/linux-x86/bin/fastboot目录下。 Fastboot命令实例:sud
文章出处:http://blog.csdn.net/geniusmen/article/details/7892398 1.Fastboot简介 Fastboot是Android快速升级的一种方法,Fastboot的协议fastboot_protocol.txt在源码目录./bootable/bootloader/legacy下可以找到。 Fastboot客户端是作为Android系统编译的一部分
1 需求 fastboot getvar all secure boot fastboot getvar secure mtp mmc emmc fastboot getvar variant fastboot getvar unlocked fastboot flashing lock|unlock flashing lock_critical|unlock_critical flashing
ember-fastboot-docker Dockerized Node.js server for running Ember FastBoot apps. Based on Ember FastBoot for AWS Elastic Beanstalk by @tomdale. Usage $ docker run \ --rm -it \ -p 8080:3000 \ -v $(p
ember-fastboot-addon-tests This is an ember-cli addon that makes testing your own addon for compatibility with FastBoot easy and straightforward! It works by using ember-cli-addon-tests to create a (t
ember-cli-deploy-fastboot-api-lambda An ambitious ember-cli-deploy plugin for serving Ember FastBoot Applications entirely from within AWS Lambda/API Gateway (assets and all!). Background API Gateway
ember-app-shell ember-app-shell is built and maintained by DockYard, contact us for expert Ember.js consulting. Renders an App Shell based on your actual running Ember.js application using Headless Ch
ember-app-scheduler Ember batches DOM updates and paints them after every run loop to prevent layout thrashing. Layout thrashing can prevent a faster First Meaningful Paint (FMP) because all the conte
ember-web-app NOTICE: official repository moved to https://github.com/zonkyio/ember-web-app This Ember addon helps you configure and manage the web app manifest and related meta tags needed to create