Skip to content

[Bug]: When trying to use the new Test Agents feature with the command npx playwright init-agents --loop=vscode, the command fails with an ENOENT error while attempting to create the agent files. #38005

@maheedhar-202

Description

@maheedhar-202

Version

  • Operating System: Windows - VS Code Version: 1.105.1 - Node.js Version: v20.9.0 - Playwright Version: 1.56.1 - Running from: VS Code integrated terminal

Steps to reproduce

  1. Set up a new or existing Playwright project
  2. Run npx playwright init-agents --loop=vscode
  3. The command attempts to create files but fails

Expected behavior

The command should successfully create the agent files in the chatmodes directory as described in the documentation at https://playwright.dev/docs/test-agents

Actual behavior

Writing file: .github/chatmodes/🎭 generator.chatmode.md
node:internal/fs/promises:590
    await binding.openFileHandle(pathModule.toNamespacedPath(path),
                  ^

Error: ENOENT: no such file or directory, open
    at open (node:internal/fs/promises:590:19)
    at Object.writeFile (node:internal/fs/promises:1019:20) 
    at writeFile ([...]/node_modules\playwright\lib\agents\generateAgents.js:169:36)
    at initVSCodeRepo ([...]/node_modules\playwright\lib\agents\generateAgents.js:227:11)
    at async i.<anonymous> ([...]/node_modules\playwright\lib\program.js:191:7) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open'
}

### Additional context

The error persists even when the [chatmodes](vscode-file://vscode-app/c:/Users/Lenovo/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html) directory is manually created with full permissions
The same error occurs both in regular VS Code terminal and when running PowerShell as administrator

### Environment

```shell
### Environment
- Operating System: Windows
- VS Code Version: 1.105.1
- Node.js Version: v20.9.0
- Playwright Version: 1.56.1
- Running from: VS Code integrated terminal

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions