Skip to content

Latest commit

 

History

History
61 lines (49 loc) · 1.24 KB

typescript.md

File metadata and controls

61 lines (49 loc) · 1.24 KB

Testplane × Typescript

To write Testplane tests on typescript, you would need to install ts-node:

npm i -D ts-node

And include Testplane types in your tsconfig.json file:

// tsconfig.json
{
    // other tsconfig options
    "compilerOptions": {
        // other compiler options
        "types": [
            // other types
            "testplane",
        ]
    }
}

Recommended config:

{
    "compilerOptions": {
        "types": [
            "testplane"
        ],
        "sourceMap": true,
        "outDir": "../test-dist",
        "target": "ESNext",
        "module": "CommonJS",
        "strict": true,
        "lib": ["esnext", "dom"],
        "esModuleInterop": true
    }
}

Note: this is the strictest possible setting, which works on Typescript 5.3+. If you want faster type-checks or have older Typescript version, use "skipLibCheck": true in compilerOptions.

testplane.ctx typings

If you want to extend testplane.ctx typings, you could use module augmentation:

import type { TestplaneCtx } from "testplane";

declare module "testplane" {
    interface TestplaneCtx {
        someVariable: string;
    }
}

Now testplane.ctx will have someVariable typings