---
# System prepended metadata

title: Testing Methodologies
tags: [' Talk', Templates]

---

---
title: Testing Methodologies
tags: Templates, Talk
description: View the slide with "Slide Mode".
---

# Testing Methodologies
## Different testing frameworks

* ***Tape***
* ***Jest***
* ***QUnit***
* ***Jasmine***
* ***Mocha***


## How are they different

***Jasmine (v2.0.1)***
Jasmine is a very popular one,It also has runners in Python and Ruby, which is incredibly useful if you want to run your client-side tests alongside your server-side ones.

***Mocha (v1.20.1)***
Mocha doesn't have an assertion library built in, so it requires an additional 3rd-party library to be added. While I appreciate the flexibility, this adds some unnecessary friction for first-time users, who need to pick one without a lot of context about why one would be a better choice than the other.

***Globals***: Mocha, Jasmine, and several other alternatives pollute the global environment with functions like `describe`, `it`, etc… Some assertion libraries extend built-in prototypes. Aside from removing the self-documenting nature of simple module exports, those decisions could potentially conflict with the code you’re trying to test. Vs: Tape’s simple module export.

# Tape

*Installation*:

npm install tape --save-dev

*We should always require Tape in our test files, like this:*

var test = require("tape");

*Documentation*:

https://github.com/substack/tape


---
# t.equal

t.equal(actual, expected, msg)

**Example (this test will not pass):**

test("Testing equal", function(t) {
  var actual = { a: [2 + 3], b: [4] };
  var expected = { a: [5], b: [4] };
  t.equal(actual, expected, "Should be equal");
  t.end();
});


---

# t.deepEqual

t.deepEqual(actual, expected, msg)

Example (this test **will** pass):

test("Testing deepEqual", function(t) {
  var actual = { a: [2 + 3], b: [4] };
  var expected = { a: [5], b: [4] };
  t.deepEqual(actual, expected, "Should be deepEqual");
  t.end();
});

**But** this one will **not**:

test("Testing deepEqual", function(t) {
  var actual = { a: [2 + 3], b: [4] };
  var expected = { a: ["5"], b: [4] };
  t.deepEqual(actual, expected, "Should be deepEqual");
  t.end();
});


---

# t.deepLooseEqual

t.deepLooseEqual(actual, expected, msg)

Example (this **will** pass);

test("Testing deepLooseEqual", function(t) {
  var actual = { a: [2 + 3], b: [4] };
  var expected = { a: ["5"], b: [4] };
  t.deepLooseEqual(actual, expected, "Should be deepLooseEqual");
  t.end();
});

---

# t.ok

t.notOk(value, msg)

Example (this will **not** pass):

test("Testing ok", function(t) {
  var actual = 2 + 3 == 7;
  t.ok(actual, "Actual should === true");
  t.end();
});

I will see the following error:

    ✖ Actual should === true
    -------------------------
      operator: ok
      expected: true
      actual:   false

---
# t.plan
t.plan(number of times the test will run), instead of **t.end()**. 

Example:

test("Testing ok", function(t) {
  t.plan(2);
  var actual = 2 + 5 == 7;
  var mistake = 2 + 5 === 8;
  t.ok(actual, "Actual should === true");
  t.ok(mistake, "Actual should === true");
});
