PROGRAMOWANIE JAVASCRIPT

Programowanie JavaScript 10

HTTP

HTTP

Client

  • curl
  • google chrome
  • firefox
  • axios
  • custom

Server

  • apache2
  • nginx
  • caddy
  • custom

Client ( Wrapper ) GitHub

CZ. 1

Aplikacja (skrypt - nasz klient) komunikujący się z zewnętrzmym API usługi (GitHub - nasz serwer) z użyciem protokołu HTTP/HTTPS. Klient powinien realizować

  • dodawanie gist-ów
  • edycje gist-ów
  • usuwanie gist-ów
  • listing gist-ów
  • filtrowanie gist-ów

Testowanie kodu

  • oszczędność czasu
  • dokumentacja
  • testy regresyjne
  • poprawa jakości kodu
  • dyscyplina
  • code coverage & performance
  • CI (Continuous Integration)

jest

konfiguracja

npm install --save-dev jest
npx jest --init #> jest.config.js

package.json

{
  ...
  "scripts": {
    ...
    "test": "jest",
    "test:watch": "npm run test -- --watch"
  },
  ...
}
npm install --save-dev babel-jest @babel/core @babel/preset-env

babel.config.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
};

jest

Sample

Ćwiczenie

  • napisać test automatyczny dla GitHubWrapper #root