Skip to content

Latest commit

 

History

History
132 lines (95 loc) · 2.74 KB

KopytkoTestFunctions.md

File metadata and controls

132 lines (95 loc) · 2.74 KB

KopytkoTestFunctions API

In order to make developer live easier there are shorhands for all test function

There is bs_const variable - insertKopytkoUnitTestSuiteArgument

  • when true all test case functions and hooks need ts (TestSuite) argument
it("should check if true is true", function (_ts as Object) as String
  return expect(true).toBeTrue()
end function)
  • when false all test case functions and hooks do not need ts (TestSuite) argument
it("should check if true is true", function () as String
  return expect(true).toBeTrue()
end function)

Functions

test

This is a shorthand for the ts.addTest.

test("it should check if true is true", function (_ts as Object) as String
  return expect(true).toBeTrue()
end function)

testEach

This is a shorthand for the ts.addParameterizedTests.

testEach([
  { value: 2, expectedValue: 2 },
  { value: "asd", expectedValue: "asd" },
], "it should check if ${value} is ${expectedValue}", function (_ts as Object, params as Object) as String
  return expect(params.value).toBe(params.expectedValue)
end function)

it

This is a shorthand for the ts.addTest.

It adds "it " to the beggining of the test name.

it("should check if true is true", function (_ts as Object) as String
  return expect(true).toBeTrue()
end function)

itEach

This is a shorthand for the ts.addParameterizedTests.

It adds "it " to the beggining of the test name.

itEach([
  { value: 2, expectedValue: 2 },
  { value: "asd", expectedValue: "asd" },
], "should check if ${value} is ${expectedValue}", function (_ts as Object, params as Object) as String
  return expect(params.value).toBe(params.expectedValue)
end function)

beforeAll

This is a shorthand for the ts.setBeforeAll.

beforeAll(sub (_ts as Object)
  ? "This will be printed before first test case execution"
end sub)

beforeEach

This is a shorthand for the ts.setBeforeEach.

beforeEach(sub (_ts as Object)
  ? "This will be printed before every test case execution"
end sub)

afterEach

This is a shorthand for the ts.setAfterEach.

afterEach(sub (_ts as Object)
  ? "This will be printed after every test case execution"
end sub)

afterAll

This is a shorthand for the ts.setAfterAll.

afterAll(sub (_ts as Object)
  ? "This will be printed after last test case execution"
end sub)

ts

Returns Test Suite object (ts).

ts().isMatch({ a: 1 }, { a: 1 })