Found in my production project after the migration from 3.x to 4.x. It works well in 3.x
Maybe the bug has the same reason as #5632 and #5635.
You can reproduce it with the Quickstart project
mirao@rog:~/workspace/my$ codeceptjs run --verbose
***************************************
nodeInfo: 24.16.0
osInfo: Linux 6.17 Ubuntu 24.04.4 LTS 24.04.4 LTS (Noble Numbat)
cpuInfo: (16) x64 AMD Ryzen 7 9700X 8-Core Processor
chromeInfo: 149.0.7827.114
edgeInfo: "N/A"
firefoxInfo: 151.0.3
safariInfo: N/A
playwrightBrowsers: "chromium: 149.0.7827.55, firefox: 151.0, webkit: 26.5"
If you need more detailed info, just run this: npx codeceptjs info
***************************************
Error: Invalid data type. Data accepts either: DataTable || generator || Array || function
at DataTable (/home/mirao/workspace/my/node_modules/codeceptjs/lib/data/context.js:117:10)
at DataTable (/home/mirao/workspace/my/node_modules/codeceptjs/lib/data/context.js:117:10)
at DataTable (/home/mirao/workspace/my/tests/My_test.ts:9:1)
at Object.<anonymous> (/home/mirao/workspace/my/tests/My_test.ts:11:2)
at Module._compile (node:internal/modules/cjs/loader:1854:14)
at Object.transformer (/home/mirao/workspace/my/node_modules/tsx/dist/register-BOkp8V6j.cjs:9:3176)
at Module.load (node:internal/modules/cjs/loader:1577:32)
at Module._load (node:internal/modules/cjs/loader:1379:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.require (node:internal/modules/cjs/loader:1600:12)
Invalid data type. Data accepts either: DataTable || generator || Array || function
Error:
at DataTable (/home/mirao/workspace/my/node_modules/codeceptjs/lib/data/context.js:117:10)
at DataTable (/home/mirao/workspace/my/node_modules/codeceptjs/lib/data/context.js:117:10)
at DataTable (/home/mirao/workspace/my/tests/My_test.ts:9:1)
at Object.<anonymous> (/home/mirao/workspace/my/tests/My_test.ts:11:2)
at Module._compile (node:internal/modules/cjs/loader:1854:14)
at Object.transformer (/home/mirao/workspace/my/node_modules/tsx/dist/register-BOkp8V6j.cjs:9:3176)
at Module.load (node:internal/modules/cjs/loader:1577:32)
at Module._load (node:internal/modules/cjs/loader:1379:12)
at wrapModuleLoad (node:internal/modules/cjs/loader:255:19)
at Module.require (node:internal/modules/cjs/loader:1600:12)
tests/My_test.ts:
import { dataTable as DataTable } from 'codeceptjs';
Feature('My');
const cases = new DataTable(['input', 'expected']);
cases.add(['input1', 'expected1']);
cases.add(['input2', 'expected2']);
Data(cases).Scenario('test something', ({ I, current }) => {
I.say(`Input: ${current.input}, Expected: ${current.expected}`);
});
codecept.conf.ts:
import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);
// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();
export const config: CodeceptJS.MainConfig = {
tests: './tests/*_test.ts',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'http://localhost',
show: true
}
},
include: {
I: './steps_file.ts'
},
noGlobals: true,
plugins: {},
name: 'my',
require: ['tsx/cjs']
}
tsconfig.json:
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM"],
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "bundler",
"strictNullChecks": false,
"types": ["codeceptjs", "node"],
"declaration": true,
"skipLibCheck": true
},
"exclude": ["node_modules"]
}
Used SW:
Found in my production project after the migration from 3.x to 4.x. It works well in 3.x
Maybe the bug has the same reason as #5632 and #5635.
You can reproduce it with the Quickstart project
tests/My_test.ts:
codecept.conf.ts:
tsconfig.json:
{ "compilerOptions": { "target": "ES2022", "lib": ["ES2022", "DOM"], "esModuleInterop": true, "module": "ESNext", "moduleResolution": "bundler", "strictNullChecks": false, "types": ["codeceptjs", "node"], "declaration": true, "skipLibCheck": true }, "exclude": ["node_modules"] }Used SW: