Skip to content

O Andrew Testing Library é uma ferramenta de teste para TypeScript e JavaScript. Ela é bem mais simples que ferramentas mais parrudas como o Jest, por exemplo, mas para testes simples deve cumprir bem seu objetivo.

Notifications You must be signed in to change notification settings

Redwars22/andrew-testing-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SETTING ANDREW TESTING LIBRARY UP

Download the latest version Andrew Testing Library here, extract it somewhere inside the folder of your project and then create a folder named test and a file named example.spec.ts, then proceed to the next section.

WRITING YOUR FIRST TEST

Paste the following code into the example.spec.ts file then save it.

import { AndrewTesting } from "../core/assert";

AndrewTesting.describe("This is your first test!", () => {
  AndrewTesting.test("Checks if the sum of two numbers is equal to 8", () => {
    const num1 = 4
    const num2 = 4;
    const sum = 8;

    AndrewTesting.shouldBeEqual(sum, 8);
  });
});

The test above checks whether the sum of two numbers is equal to 8. Now open your terminal at the folder where you saved your test and type node example.spec.js (note that you should compile your TypeScript file to JavaScript first). You should get the following output in the terminal:

describe(title, () => {}) creates a test suit, a group of tests, whereas test(title, () => {}) refers to each one of the tests.

MATCHERS

  • shouldBeEqual
  • shouldNotBeEqual
  • shouldBeStrictEqual
  • shouldNotBeStrictEqual
  • shouldBeNull
  • shouldNotBeNull
  • shouldBeUndefined
  • shouldNotBeUndefined
  • shouldBeTruthy
  • shouldBeFalsy

MATCHERS FOR NUMBERS

  • shouldBeGreaterThan
  • shouldNotBeGreaterThan
  • shouldBeGreaterThanOrEqual
  • shouldNotBeGreaterThanOrEqual
  • shouldBeLessThan
  • shouldNotBeLessThan
  • shouldNotBeLessThanOrEqual

MATCHERS FOR COMPARING ARRAYS AND OBJECTS

  • shouldBeEqualArr (for arrays)
  • shouldNotBeEqualArr (for arrays)
  • shouldBeEqualObj (for objects)
  • shouldNotBeEqualObj (for objects)

About

O Andrew Testing Library é uma ferramenta de teste para TypeScript e JavaScript. Ela é bem mais simples que ferramentas mais parrudas como o Jest, por exemplo, mas para testes simples deve cumprir bem seu objetivo.

Resources

Stars

Watchers

Forks

Packages

No packages published