Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ecossistema de Testes com JavaScript

Ecossistema de Testes com JavaScript

Ecossistema de Testes com JavaScript

More Decks by Jonathan Cruz Rocha Ferreira

Other Decks in Programming

Transcript

  1. Testes Unitários O teste unitário tem por objetivo testar a

    menor parte testável do sistema (unidade), em geral, um método. Idealmente, o teste unitário é independente de outros testes, validando assim cada parte ou funcionalidade individualmente.
  2. Respondendo algumas perguntas O que eu estou testando? O que

    o método deveria fazer? Qual o seu atual retorno? O que eu espero que retorne?
  3. Ferramentas existem poucas MochaJS Jasmine Jest Cucumber Chai Unexpected Karma

    Ava Sinon Enzyme Testdouble Istanbul Blanket Protractor PhantomJS Casper Nightwatch Cypress.io
  4. Estrutura de testes Mocha, Jasmine, Jest e Cucumber // 1

    - beforeAll // 1 - beforeEach // 1 - test // 1 - afterEach // 2 - beforeAll // 1 - beforeEach // 2 - beforeEach // 2 - test // 2 - afterEach // 1 - afterEach // 2 - afterAll // 1 - afterAll
  5. Funções de Validação, asserts Chai, Jasmine, Jest e Unexpected .toBeNull()

    .toBeTruthy() .toBeUndefined() .toContain(item) .toEqual(value) .toHaveLength(int) .toBe() https://jestjs.io/docs/en/expect.html
  6. Mocks, Spies e Stubs Sinon, Jasmine, enzyme, jest e testdouble

    https://medium.com/@rickhanlonii/understanding-jest-mocks-f0046c68e53c