- Backbone.js Testing
- Ryan Roemer
- 243字
- 2021-08-13 16:48:29
Designing an application and test repository structure
Setting up a test infrastructure first requires a plan as to where all the parts and pieces will go. We will start with a simple directory structure for a code repository as follows:
app/ index.html css/ js/ app/ lib/ test/ test.html js/ lib/ spec/
The app/index.html
file contains the web application, while test/test.html
provides the test driver page. Application and test libraries are respectively contained in the app/js/
and test/js/
directories.
Note
This is just one way to organize a Backbone.js application and tests. Other directory layouts may be more appropriate, and you should feel free to follow your own conventions and preferences in light of the specific development project at hand.
The Backbone.js application and component files (models, views, routers, and so on) are placed in app/js/app/
, which may look something like the following:
app/js/app/ app.js models/ model-a.js ... views/ view-a.js ... ...
The core application libraries are stored in app/js/lib/
, which should include the libraries needed to drive the actual application:
app/js/lib/ backbone.js jquery.js underscore.js ...
The test libraries and suites get a separate directory, test/js/
, which isolates the test code from the application to avoid inadvertently introducing application dependencies on test functions or libraries:
test/js/ lib/ mocha.js mocha.css chai.js sinon.js spec/ first.spec.js second.spec.js ...
Now that we have an abstract application and a test layout, we need to fill in all the pieces and populate directories with libraries, web pages, and test files.
- Learning Selenium Testing Tools with Python
- PHP+MySQL網(wǎng)站開(kāi)發(fā)技術(shù)項(xiàng)目式教程(第2版)
- Spring Boot+Spring Cloud+Vue+Element項(xiàng)目實(shí)戰(zhàn):手把手教你開(kāi)發(fā)權(quán)限管理系統(tǒng)
- Python網(wǎng)絡(luò)爬蟲從入門到實(shí)踐(第2版)
- R語(yǔ)言數(shù)據(jù)可視化實(shí)戰(zhàn)
- Python自然語(yǔ)言處理(微課版)
- 21天學(xué)通C++(第6版)
- Reactive Programming With Java 9
- Symfony2 Essentials
- Serverless computing in Azure with .NET
- C#程序設(shè)計(jì)教程(第3版)
- 汽車人機(jī)交互界面整合設(shè)計(jì)
- 單片機(jī)原理及應(yīng)用技術(shù)
- C語(yǔ)言程序設(shè)計(jì)
- 你真的會(huì)寫代碼嗎