1.0.6 • Published 2 years ago

ngt-unit-test v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Hỗ trợ automation testing

Import

const { post, get } = require("ngt-unit-test");
const { RANGE, ACCURACY, EXIST, NOT_EXIST, UNIQUE } =
  require("ngt-unit-test").type;

Run

- Chạy file test với mocha
- Thay đổi script trong package.json: "test": "mocha ./**.test.js"
- RUN: npm test

Type Testing

RANGE - Test trong giới hạn đi kèm với thuộc tính low và high
ACCURACY - Test chính xác giá trị đi kèm thuộc tính value
EXIST - Test truthy
NOT_EXIST - Test falsy
UNIQUE - Test giá trị duy nhất

Test method post

post(input, expected)

VD: post({
        domain: 'https://...',
        api: '/api/...',
        query: {
            id: ...
        },
        quantity: 2,
        body: {
            username: 'Admin',
            password: '******'
        },
        token: 'abc.......'
    }, {
        error: { typeTesting: NOT_EXIST },
        data: {
            image: { typeTesting: EXIST },
            username: { typeTesting: ACCURACY, value: "maxsida" },
            amount: { typeTesting: RANGE, low: 1000, high: 10000}
        }
    })

Test method get

get(input, expected)

VD: get({
        domain: 'https://...',
        api: '/api/...',
        query: {
            id: ...
        },
        quantity: 2,
        token: 'abc.......'
    }, {
        data: {
            image: { typeTesting: EXIST }
        }
    })

Test array

get(input, expected)

VD: get({
        domain: 'https://...',
        api: '/api/...',
        query: {
            id: ...
        },
        quantity: 2
    }, {
        error_code: {typeTesting: NOT_EXIST},
        data: [
            {
                id: { typeTesting: UNIQUE },
                image: { typeTesting: EXIST },
                rating: { typeTesting: ACCURACY, value: "R" },
            }
        ],
        error_msg: { typeTesting: NOT_EXIST}
    })
1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago