I am trying to create a practice environment for CodeceptJS using TS and Playwright, but for some reason VSCodes intellisense refuses to show any suggestions. I can manually type the code and that is fine and works but I would like to get the intellisense working.
I have followed the quickstart guide on the CodeceptJS website to the letter with the following steps:
- Open directory and execute command
npx create-codeceptjs .
this does annpm init
and then installs all of the required packages for Codecept and playwright before finally doing annpx codeceptjs init
which creates the boilerplate TS project. - In this project I have the following files:
tsconfig.json
{
"ts-node": {
"files": true
},
"compilerOptions": {
"target": "es2018",
"lib": ["es2018", "DOM"],
"esModuleInterop": true,
"module": "commonjs",
"strictNullChecks": false,
"types": ["codeceptjs", "node"],
"declaration": true,
"skipLibCheck": true
},
"exclude": ["node_modules"]
}
steps.d.ts
/// <reference types='codeceptjs' />
type steps_file = typeof import('./steps_file');
declare namespace CodeceptJS {
interface SupportObject { I: I, current: any }
interface Methods extends Playwright {}
interface I extends ReturnType<steps_file> {}
namespace Translation {
interface Actions {}
}
}
steps_files.ts
// in this file you can append custom step methods to 'I' object
module.exports = function() {
return actor({
// Define custom steps here, use 'this' to access default methods of I.
// It is recommended to place a general 'login' function here.
});
}
package.json
{
"name": "codeceptjs-tests",
"version": "0.1.0",
"private": true,
"scripts": {
"codeceptjs": "codeceptjs run --steps",
"codeceptjs:headless": "HEADLESS=true codeceptjs run --steps",
"codeceptjs:ui": "codecept-ui --app",
"codeceptjs:demo": "codeceptjs run --steps -c node_modules/@codeceptjs/examples",
"codeceptjs:demo:headless": "HEADLESS=true codeceptjs run --steps -c node_modules/@codeceptjs/examples",
"codeceptjs:demo:ui": "codecept-ui --app -c node_modules/@codeceptjs/examples"
},
"devDependencies": {
"@codeceptjs/configure": "^0.10.0",
"@codeceptjs/examples": "^1.2.1",
"@codeceptjs/ui": "^0.5.0",
"@types/node": "^20.0.0",
"codeceptjs": "^3.4.1",
"playwright": "^1.33.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
}
}
login_test.ts
Feature('login');
Scenario('test something', ({ I }) => {
});
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: './*_test.ts',
output: './output',
helpers: {
Playwright: {
url: 'https://www.saucedemo.com',
show: true,
browser: 'chromium'
}
},
include: {
I: './steps_file'
},
name: 'CodeceptJS'
}
With all of this as the standard files that you get from the installation when attempting to call a standard method from Playwright amOnPage();
from the I
object of codeceptjs in my login_test.ts
file, I get no intellisense to show the possible methods. I have looked all over google and cannot find a reason for this to be happening, any help would be appreciated.