Jest

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

If file 'myCoolFile.test.js' fails, why does Jest say that every test failed?

This statement is wrong: Jest will say the file failed, BUT will also list the individual tests that passed or failed.

T/F: this test will pass with the following expect(): expect(isNull()).toBe(null)

True.

T/F: You can't use toBe() when testing for object or array equality.

True: you need to use toEqual() instead.

What is Jest?

A JavaScript testing framework with a focus on simplicity and support for large web applications.

In addition to toBe(), there are 5 other common toBe[...] functions. What are they?

DUNFT toBeDefined() toBeUndefined() toBeNull() toBeFalsy() toBeTruthy()

T/F: this test will pass with the following expect(): expect(isNull()).toBe(undefined)

False.

T/F: The following test will evaluate to true expect(someObject).toContain("propA") when someObject = {propA: "something"}.

False: this only works on arrays. HOWEVER, the following DOES evaluate to true: expect(Object.keys(someObject)).toContain("propA")

If you have a file named 'movies.js', What should the test file be?

movies.test.js

Edit this function to assert a falsehood. Don't forget to update the description and toBe()! test('adds 1 + 1 to equal 2', () =>{ expect(add(1, 1)).toBe(2); }

test('adds 1 + 1 to NOT equal 3', () =>{ expect(add(1, 1)).not.toBe(3); }

Given function 'add' which adds two numbers, write a test, and give it a description.

test('adds 1 + 1 to equal 2', () =>{ expect(add(1, 1)).toBe(2); }

If you are working with asynchronous data in Jest, what must you add in the relevant tests?

test.assertions([number of assertions])

Describe the different use cases for toBe() and toEqual().

toBe() is for primitive data types; toEqual is for referenced data (like objects and arrays).

If you wanted to check if a value was [LT, LTE, GT, GTE] which method would you call?

toBeLessThan toBeLessThanOrEqual toBeGreaterThan toBeGreaterThanOrEqual

What method is used to match Regex?

toMatch()


Ensembles d'études connexes

Final Review Outline + PQ Issues

View Set

2.3 Identification and Authentication

View Set

CH 20; Program Design and technique for aerobic endurance training

View Set

Ch. 5 Practice Questions Part 1 #'s 451-480 - Doppler Instrumentation and Hemodynamics

View Set

Español 1020 Repaso (Capítulo 7)

View Set

Level 23: Mortgage Brokers - Chapter 1: Mortgage Origination

View Set