Giter VIP home page Giter VIP logo

ls-testing's Introduction

Testing

Topics:

Project Description

  • Welcome to the wonderful world of Test Driven Development. Whether this is immediately clear to you or not, you have already familiarized yourselves with this process, only, the tests have been written for you beforehand. Now we start on the other side of the fence, where you have no tests, only working code. The goal of this sprint is to get you familiar with writing unit tests for JavaScript code.

Initialize Project

  • Be sure to npm install to include the necessary dependancies.
  • To run your tests run the command over the corresponding directory/file that you're working in. ex. npm run watch basic-javascript/tests/project-1.test.js.
    • This command will actually re-execute every time a change is saved in that file, so you can see your tests improve without having to run the command over and over again.
  • Once you're done with all the tests for that directory, run npm test directory/tests.
  • Get started in the basic-javascript directory then move onto advanced-javascript when you're done.

Notes/Hints

  • Have fun watching your Nyan cat grow!
  • Test suite
  // a test suite is made up of test assertions. 
  // you can have multiple suites in a file. In mocha we use `describe()` to wrap a suite.
  // you can also have a suite full of suites.

  describe('Foo', () => { // this is a suite
    describe('Foo.bar', () => { // this is a suite
      it('should be a function', () => { // this is an assertion block
        const foo = foo.bar;
        expect(foo).to.be.a('function'); // this is an assertion using `expect`
        assert.typeOf(foo, 'function'); // this is an assertion using `assert`
      });
    });
  });
  • sinon spy example
  // an example of a spy using sinon. 
    it('should call a given callback', () => {
      const callBack = sinon.spy();
      const each = arrayFunctions.each;
      each([1,2], callBack);
      expect(callBack).to.have.callCount(2); // will pass test
    });

Extra Credit

  • Congratulations you wonderful developer you! You have survived the basic requirements and are now ready to put your big TDD skills to the test!
  • Pop open the node-extra-credit file and study up on testing node endpoints.
  • Use either assert or expect its your time to shine so pick a style and stick with it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.