This file provides context for the Gemini AI code assistant.
src: Main source code.tests: E2E tests.lib: Generated files (do not edit).
- Do not commit, pull, or push unless explicitly asked.
To restore the project to a known good state, run the following commands in order:
- Build:
npm run build - Unit Tests:
npm run unit - Format:
npm run format - Verify BidiMapper Import:
node lib/esm/bidiMapper/BidiMapper.js. If this fails withERR_MODULE_NOT_FOUND, it's likely due to a missing.jsextension in an import statement in one of the TypeScript source files.
- Unit test source files are located in the
srcdirectory and have a.spec.tsextension. - They are co-located with the code they are testing.
- Run unit tests with
npm run unit. This command first compiles the TypeScript code (including tests) into JavaScript in thelibdirectory and then runs the tests using Mocha. - When adding new tests, create a new
*.spec.tsfile in thesrcdirectory next to the file you are testing. The build process will automatically pick it up. - Important: Do not delete the test files you create. They are a part of the project.
- Use constants for test data like user context or browsing context IDs to improve readability and maintainability.
To run a specific E2E test, use the following command:
npm run e2e -- -k <test_name>
To debug a failing E2E test, try running it with different environment variables:
- Set
HEADLESStotrue,false, orold. - Set
CHROMEDRIVERtotrueorfalse.
Each run should be done with VERBOSE=true. Inspect the latest log in the logs
directory for errors.
Note: E2E tests are slow, so run only the necessary tests.
To checkout a pull request:
git fetch origin pull/<PR_NUMBER>/head:<BRANCH_NAME>
git checkout <BRANCH_NAME>After each checkout, run npm run clean.
When asked to fix a PR, get it's title. If it's title is something like
build(spec): update WebDriverBiDi types, it means a new command was added to the
WebDriver BiDi CDDL. Run the following steps to fix it:
- Check out the Pull Request. The PR is usually created by
browser-automation-bot, and the branch name is usuallyupdate-bidi-types. - Run
npm run clean && npm run format:eslint. This will fail with aSwitch is not exhaustiveerror. - Implement the parser for the new command's params:
- Add the new
parse...method to theBidiCommandParameterParserinterface insrc/bidiMapper/BidiParser.ts. - Implement the new
parse...method insrc/bidiMapper/BidiNoOpParser.ts. - Implement the new
parse...method insrc/bidiTab/BidiParser.ts. - Add the new
parse...function to the corresponding namespace insrc/protocol-parser/protocol-parser.ts.
- Add the new
- Add the new command to
src/bidiMapper/CommandProcessor.ts. Add a newcasefor the new command in theswitchstatement. First parse the command parameters and then throw an exception. - Run
npm run buildandnpm run formatto verify the fix. - Do not commit the changes.
- Do not run e2e tests for this kind of fixes.