菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
405
0

Jasmine

原创
05/13 14:22
阅读数 79605

Jasmine

https://www.npmjs.com/package/jasmine

 

 

The Jasmine Module

The jasmine module is a package of helper code for developing Jasmine projects for Node.js.

The core of jasmine lives at https://github.com/jasmine/jasmine and is jasmine-core in npm.

Contents

This module allows you to run Jasmine specs for your Node.js code. The output will be displayed in your terminal by default.

 

Installation

# Local installation: 
npm install --save-dev jasmine
 
# Global installation 
npm install -g jasmine

Initializing

To initialize a project for Jasmine

jasmine init

To seed your project with some examples

jasmine examples

 

https://jasmine.github.io/setup/nodejs.html

Note that if you installed Jasmine locally you could still use the command line like this:

node node_modules/jasmine/bin/jasmine init

 

DEMO

describe("A suite", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

 

 

 

 

API

https://jasmine.github.io/api/3.0/global.html#expect

 

describe(description, specDefinitions)

Create a group of specs (often called a suite).

Calls to describe can be nested within other calls to compose your suite as a tree.

Parameters:
NameTypeDescription
description String

Textual description of the group

specDefinitions function

Function for Jasmine to invoke that will define inner suites and specs

expect(actual) → {matchers}

Create an expectation for a spec.

Parameters:
NameTypeDescription
actual Object

Actual computed value to test expectations against.

发表评论

0/200
405 点赞
0 评论
收藏