Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions test/data/typescript-esm-exports/codecept.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const config: CodeceptJS.MainConfig = {
tests: "./*.ts",
output: "./output",
helpers: {
FileSystem: {},
},
name: "container-esm",
require: ["tsx/cjs"],
};
5 changes: 5 additions & 0 deletions test/data/typescript-esm-exports/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "container-esm",
"version": "1.0.0",
"private": true
}
107 changes: 107 additions & 0 deletions test/data/typescript-esm-exports/test-all-exports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import {
container,
codecept,
output,
event,
recorder,
config,
actor,
helper,
pause,
within,
dataTable,
dataTableArgument,
store,
locator,
// Secret,
// secret,
} from "codeceptjs";
import { expect } from "chai";

Feature("Import all exports from codeceptjs");

Scenario("container should be importable as named export", () => {
expect(container).to.exist;
expect(container.helpers).to.be.a("function");

const helpers = container.helpers();
console.log("Available helpers:", Object.keys(helpers));
});

Scenario("codecept should be importable", () => {
expect(codecept).to.exist;
});

Scenario("output should be importable", () => {
expect(output).to.exist;
expect(output.print).to.be.a("function");
output.print("Testing output.print");
});

Scenario("event should be importable", () => {
expect(event).to.exist;
expect(event).to.be.an("object");
expect(event.dispatcher).to.exist;
});

Scenario("recorder should be importable", () => {
expect(recorder).to.exist;
expect(recorder).to.be.an("object");
expect(recorder.start).to.be.a("function");
});

Scenario("config should be importable", () => {
expect(config).to.exist;
expect(config.get).to.be.a("function");
});

Scenario("actor should be importable", () => {
expect(actor).to.exist;
expect(actor).to.be.a("function");
});

Scenario("helper should be importable", () => {
expect(helper).to.exist;
});

Scenario("pause should be importable", () => {
expect(pause).to.exist;
});

Scenario("within should be importable", () => {
expect(within).to.exist;
expect(within).to.be.a("function");
});

Scenario("dataTable should be importable", () => {
expect(dataTable).to.exist;
});

Scenario("dataTableArgument should be importable", () => {
expect(dataTableArgument).to.exist;
});

Scenario("store should be importable", () => {
expect(store).to.exist;
expect(store).to.be.an("object");
expect(store.debugMode).to.exist;
});

Scenario("locator should be importable", () => {
expect(locator).to.exist;
expect(locator.build).to.be.a("function");
});

// Secret and secret are not exported from lib/index.js in older versions, so skip them
// Scenario("Secret should be importable", () => {
// expect(Secret).to.exist;
// expect(Secret.secret).to.be.a("function");
// });

// Scenario("secret should be importable", () => {
// expect(secret).to.exist;
// expect(secret).to.be.a("function");
//
// const mySecret = secret("my-password");
// expect(mySecret.toString()).to.equal("my-password");
// });
12 changes: 12 additions & 0 deletions test/data/typescript-esm-exports/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { container } from "codeceptjs";
import { expect } from "chai";

Feature("Import container as named export");

Scenario("container should be importable as named export", () => {
expect(container).to.exist;
expect(container.helpers).to.be.a("function");

const helpers = container.helpers();
console.log("Available helpers:", Object.keys(helpers));
});
97 changes: 97 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,8 +635,105 @@ declare namespace Mocha {
}
}

// Internal API types
declare module 'codeceptjs' {
export default codeceptjs

/**
* Dependency Injection Container
* Provides access to helpers, support objects, plugins, and translation
*/
export const container: typeof CodeceptJS.Container

/**
* Test runner class
*/
export const codecept: typeof CodeceptJS.Codecept

/**
* Output module for printing messages
*/
export const output: typeof CodeceptJS.output

/**
* Event dispatcher for listening to CodeceptJS events
*/
export const event: typeof CodeceptJS.event

/**
* Global promise chain recorder
*/
export const recorder: CodeceptJS.recorder

/**
* Configuration module
*/
export const config: typeof CodeceptJS.Config

/**
* Actor (I) constructor
*/
export const actor: CodeceptJS.actor

/**
* Base Helper class
*/
export const helper: typeof CodeceptJS.Helper

/**
* Pause execution until user input
*/
export const pause: typeof CodeceptJS.pause

/**
* Execute steps within specific context
*/
export const within: typeof CodeceptJS.within

/**
* Create data tables for data-driven tests
*/
export const dataTable: typeof CodeceptJS.DataTable

/**
* Create data table arguments
*/
export const dataTableArgument: typeof CodeceptJS.DataTableArgument

/**
* Shared store for test data
*/
export const store: typeof CodeceptJS.store

/**
* Locator builder
*/
export const locator: typeof CodeceptJS.Locator

/**
* Auto-healing module
*/
export const heal: any

/**
* AI assistant module
*/
export const ai: any

/**
* Workers for parallel execution
*/
export const Workers: any

/**
* Secret value type for sensitive data
*/
export const Secret: typeof CodeceptJS.Secret

/**
* Create a secret value
*/
export const secret: typeof CodeceptJS.Secret.secret
}

declare module '@codeceptjs/helper' {
Expand Down