TESTING YOUR APPLICATIONS

Testing Your Application

Types of Test?

 

  • Unit Test

 

  • Integration Test

 

  • End to End (E2E) Testing

 

Setting up your test env.

Test runners:

Execute test and summarise results (Mocha)

 

Assertion Libraries:

Define test logic and conditions (Chai)

 

Does both?

Jest

 

 

 

 

Headless Browsers: E2E Testing

 

Simulates browser interaction . e.g Puppeteer

 

Package.json

Types of Test?

 

  • Unit Test

 

  • Integration Test

 

  • End to End (E2E) Testing

 

{
  "name": "App Name",
    "version": "0.0.1",
      "main": "app.js",
        "scripts": {
          "start": "webpack app.js --mode development --watch",
            "test": "echo \"Error: no test specified\" && exit 1",
      },
        "keywords": [
          "testing",
          "javascript",
          "jest"
        ]
}

yarn add jest && devDpn

Types of Test?

 

  • Unit Test

 

  • Integration Test

 

  • End to End (E2E) Testing

 

{
  "name": "App Name",
    "version": "0.0.1",
      "main": "app.js",
        "scripts": {
          "start": "webpack app.js --mode development --watch",
            "test": "jest",
      },
        "keywords": [
          "testing",
          "javascript",
          "jest"
        ]
}
Jest docs

https://jestjs.io/docs/en/getting-started​​

https://jestjs.io/docs/en/getting-started​​

Testing An Application

Types of Test?

 

  • Unit Test

 

  • Integration Test

 

  • End to End (E2E) Testing

 

// yarn add jest
// util.test.js
// util.speck.js


// import generateText component

const { generateText } = require('./util');


test('component should do this and this', () => {
  	const text = generateText('Papa Dadson', 24);
  	expect(text).toBe('Papa Dadson is 24 years old');
})

Assignment

Add a basic test with JEST to a VUE/React application you have built

RESOURCES FOR READING:

Testing Your Applications

By Kingsley

Testing Your Applications

  • 4