Skip to main content

Testing

DeviceScript provides a unit test framework that runs on the device. It has a syntax similar to Jest/Mocha/Chai.

Setup

Configure your project for testing using this command

devs add test

Defining tests

The test framework provides the popular BDD test contructs: describe, test, expect.

import { describe, test, expect } from "@devicescript/test"

describe("this is a test suite", () => {
test("this is a test", () => {
expect(1).toBe(1)
})
})

Running tests

From a terminal, run the test DeviceScript

npm run test

See also