Internationalisation
Bundled Plugins API
Specification
A Specification is a list of definitions which will be run in sequence, and the results are collated. It is often created via the describe function.
Example usage:
1
local spec = require "cp.spec"
2
local describe, it = spec.describe, spec.it
3
4
return describe "a specification" {
5
it "performs an assertion"
6
:doing(function()
7
assert(true, "should not fail")
8
end),
9
}
Copied!

API Overview

  • Functions - API calls offered directly by the extension
  • is
  • Constructors - API calls which return an object, typically one that offers API methods
  • Methods - API calls which can only be made on an object returned by a constructor
  • run
  • with

API Documentation

Functions

is

Signature
cp.spec.Specification.is(instance) -> boolean
Type
Function
Description
Checks if the instance is an instance of Specification.
Returns
  • true if it's a Specification instance.

Constructors

Signature
cp.spec.Specification(name) -> cp.spec.Specification
Type
Constructor
Description
Creates a new test suite.

Methods

Signature
cp.spec.Specification:onAfterEach(afterEachFn) -> cp.spec.Specification
Type
Method
Description
Specifies a function to execute after each of the contained specifications is run.
Parameters
  • afterEachFn - The function to run after each child runs.
Returns
  • The same cp.spec.Specification instance.
Signature
cp.spec.Specification:onBeforeEach(beforeEachFn) -> cp.spec.Specification
Type
Method
Description
Specifies a function to execute before each of the contained specifications is run.
Parameters
  • beforeEachFn - The function to run before each child runs.
Returns
  • The same cp.spec.Specification instance.

run

Signature
cp.spec.Specification:run() -> cp.spec.Run
Type
Method
Description
Runs the specification, returning the Run instance, already running.
Returns
  • The Run instance.

with

Signature
cp.spec.Specification:with(...) -> self
Type
Method
Description
Adds the provided definitions to the suite.
Parameters
Returns
  • The same Specification instance, with the definitions added.
Last modified 1mo ago