Jest

單元測試

npm install --save-dev jest

sum.js 檔

function sum(a, b) {
  return a + b
}
module.exports = sum

sum.test.js 檔

const sum = require('./sum')

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

package.json 檔

{
  "scripts": {
    "test": "jest"
  }
}

整合測試

參考練習題

延伸閱讀

results matching ""

    No results matching ""