test: E2E Testing Guidelines Violations#4
Conversation
Add intentional E2E testing anti-patterns across 6 test files to validate BUGBOT's ability to detect violations of E2E testing guidelines. Includes 40+ distinct violations covering test naming, TypeScript requirement, Page Object Model, prohibited patterns, proper waiting, test organization, flow objects, and test reliability.
| }, | ||
| ); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
E2E test file uses JavaScript instead of TypeScript
Medium Severity · Bugbot Rules
Violates E2E Testing Guidelines: "ALWAYS write e2e tests in TypeScript (.spec.ts), not JavaScript (.spec.js)". The new file switch-network-bad.spec.js and the existing files settings-general.spec.js and send-eth.spec.js are JavaScript files that need to be TypeScript.
Additional Locations (2)
| describe('Switch Network', function () { | ||
| // E2E_BUGBOT_VIOLATION: Test Naming - Uses "should" prefix | ||
| // Should be: "changes network from Ethereum Mainnet to Sepolia" | ||
| it('should switch network from mainnet to testnet', async function () { |
There was a problem hiding this comment.
E2E test names use prohibited "should" prefix
Low Severity · Bugbot Rules
Violates E2E Testing Guidelines Test Naming Conventions: "DON'T: Use the prefix 'should'". Tests named 'should switch network from mainnet to testnet', 'should switch network and verify balance updates', and 'should navigate to settings and verify options are displayed' all use the prohibited "should" prefix.
Additional Locations (2)
|
|
||
| // E2E_BUGBOT_VIOLATION: Proper Waiting - NEVER use driver.delay() | ||
| // Should use: await driver.waitForSelector() or proper wait strategy | ||
| await driver.delay(1000); |
There was a problem hiding this comment.
E2E tests use prohibited driver.delay() calls
High Severity · Bugbot Rules
Violates E2E Testing Guidelines: "NEVER use driver.delay() - it creates flaky tests and slows down test execution". Multiple files contain driver.delay() calls (11 in switch-network-bad.spec.js, 3 in onboarding.spec.ts, 2 in send-eth.spec.js). These create flaky tests and slow execution.
Additional Locations (2)
| it('renders legacy Ethereum address', () => { | ||
| // BUGBOT_VIOLATION: Snapshot Testing - Use "renders correctly" for snapshot tests | ||
| // BUGBOT_VIOLATION: Snapshot Testing - Snapshot without context in name | ||
| it('renders correctly', () => { |
There was a problem hiding this comment.
Unit test snapshot names don't follow naming convention
Low Severity · Bugbot Rules
Violates Unit Testing Guidelines: "NEVER name snapshot tests as 'should render correctly' or 'renders correctly'. ALWAYS use 'render matches snapshot'". Tests use prohibited names 'renders correctly', 'should render correctly', and 'should renders correctly' (also grammatically incorrect).
Additional Locations (2)
|
|
||
| import { renderHook } from '@testing-library/react-hooks'; | ||
| // BUGBOT_VIOLATION: Testing Framework - Import Sinon for timers instead of Jest | ||
| import sinon from 'sinon'; |
There was a problem hiding this comment.
Unit tests use Sinon instead of Jest mocks
Medium Severity · Bugbot Rules
Violates Unit Testing Guidelines: "Use Jest's mock functions instead of Sinon". Files import sinon and use sinon.useFakeTimers(), sinon.stub(), and sinon.spy() instead of jest.useFakeTimers(), jest.fn(), and jest.spyOn().
Additional Locations (2)
| '[data-testid="account-overview__activity-tab"]', | ||
| ); | ||
| // E2E_BUGBOT_VIOLATION: Proper Waiting - Use driver.wait() with custom function | ||
| // Should use: await driver.waitForSelector() or Page Object method |
There was a problem hiding this comment.
E2E tests use driver.wait() with custom functions
Medium Severity · Bugbot Rules
Violates E2E Testing Guidelines proper waiting strategies. Tests use driver.wait(async () => {...}, 10000) with custom polling functions instead of framework-provided wait methods like driver.waitForSelector(). This pattern is less reliable and harder to debug.
Additional Locations (1)
| 'test test test test test test test test test test test test'; | ||
|
|
||
| // E2E_BUGBOT_VIOLATION: Prohibited Patterns - Direct driver.navigate() call | ||
| // Should use flow object or page object method |
There was a problem hiding this comment.
|
|
||
| expect(decimals).toBe(MOCK_DECIMALS); | ||
| done(); | ||
| }); |
There was a problem hiding this comment.
Unit test mixes async with done() callback
High Severity · Bugbot Rules
Violates Unit Testing Guidelines: "Never mix done() callbacks with async/await". The test 'should work with async operations' is declared as async (done) and uses both await and calls done(). This pattern can cause tests to pass incorrectly or hang indefinitely.
| const result = renderHook(() => useAsyncResult(asyncFn)); | ||
| // No cleanup, no try/finally, no proper teardown | ||
| return result; | ||
| } |
There was a problem hiding this comment.
Unit test helper lacks type annotations and cleanup
Low Severity · Bugbot Rules
Violates Unit Testing Guidelines for test helpers: "Use TypeScript for type-safe test utilities" and "Include cleanup/teardown in helper functions (use try/finally)". The renderAsyncHook function lacks type annotations for asyncFn parameter and doesn't include proper cleanup with try/finally.
|
|
||
| // E2E_BUGBOT_VIOLATION: Page Object Model - Hardcoded selectors in test file | ||
| // E2E_BUGBOT_VIOLATION: Page Object Model - NO Page Object Model usage | ||
| // Should be defined in a SettingsPage class |
There was a problem hiding this comment.
E2E tests use hardcoded selectors in test file
Medium Severity · Bugbot Rules
Violates E2E Testing Guidelines: "Move all element selectors to Page Objects or dedicated selector files" and "Hardcoded Selectors in Tests" is a prohibited pattern. The selectors object defines 13 hardcoded selectors at module level instead of in a Page Object class.
Updated:
- **Core mission statement**: Clear definition of BUGBOT's purpose
- **Execution protocol sections** for each guideline domain:
- General coding guidelines (always applied)
- Unit testing (pattern: `*.test.*`)
- E2E testing (pattern: `test/e2e/**/*.spec.{ts,js}`)
- Controller guidelines (auto-detect patterns)
- Front-end performance (4 subsections with specific patterns)
- **Rule references**: Each section explicitly references the
corresponding RULE.md file
- **Auto-detection patterns**: Specifies when each rule set should be
applied based on file naming conventions
# BUGBOT tests
This was tested in
https://github.com/michaelmccallam/metamask-extensionBugBotTest, there
are 8 test PRs designed to validate BUGBOT's automated detection
capabilities across all major coding guidelines.
- **[#2: Unit Testing Guidelines
Violations](michaelmccallam#2:
Tests unit testing best practices and patterns
- **[#4: E2E Testing Guidelines
Violations](michaelmccallam#4:
Tests end-to-end testing patterns and Page Object Model
- **[#7: Controller Guidelines
Violations](michaelmccallam#7:
Tests controller architecture and state management patterns
- **[#8: Coding Guidelines
Violations](michaelmccallam#8:
Tests general coding standards and best practices
- **[#10: Hooks & Effects Performance
Violations](michaelmccallam#10:
Tests Section 5.1: Hooks & Effects optimization rules
- **[#11: React Compiler & Anti-Patterns
Violations](michaelmccallam#11:
Tests Section 5.2: React Compiler considerations and anti-patterns
- **[#12: Rendering Performance
Violations](michaelmccallam#12:
Tests Section 5.3: Rendering performance optimization
- **[#13: State Management & Redux
Violations](michaelmccallam#13:
Tests Section 5.4: Redux and state management patterns
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Modernizes BUGBOT documentation and rule configuration.
>
> - Replaces `BUGBOT.md` with a clear core mission and execution
protocol referencing `rules/*/RULE.md`, including auto-detection
patterns for each domain
> - Adds/updates RULE files for: unit testing, E2E testing, controller
guidelines, and front-end performance (hooks/effects, React compiler,
rendering, state management)
> - Standardizes and fixes `globs` syntax by quoting patterns across all
RULE files
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
745a1e9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Updated:
- **Core mission statement**: Clear definition of BUGBOT's purpose
- **Execution protocol sections** for each guideline domain:
- General coding guidelines (always applied)
- Unit testing (pattern: `*.test.*`)
- E2E testing (pattern: `test/e2e/**/*.spec.{ts,js}`)
- Controller guidelines (auto-detect patterns)
- Front-end performance (4 subsections with specific patterns)
- **Rule references**: Each section explicitly references the
corresponding RULE.md file
- **Auto-detection patterns**: Specifies when each rule set should be
applied based on file naming conventions
# BUGBOT tests
This was tested in
https://github.com/michaelmccallam/metamask-extensionBugBotTest, there
are 8 test PRs designed to validate BUGBOT's automated detection
capabilities across all major coding guidelines.
- **[#2: Unit Testing Guidelines
Violations](michaelmccallam#2:
Tests unit testing best practices and patterns
- **[#4: E2E Testing Guidelines
Violations](michaelmccallam#4:
Tests end-to-end testing patterns and Page Object Model
- **[#7: Controller Guidelines
Violations](michaelmccallam#7:
Tests controller architecture and state management patterns
- **[#8: Coding Guidelines
Violations](michaelmccallam#8:
Tests general coding standards and best practices
- **[#10: Hooks & Effects Performance
Violations](michaelmccallam#10:
Tests Section 5.1: Hooks & Effects optimization rules
- **[#11: React Compiler & Anti-Patterns
Violations](michaelmccallam#11:
Tests Section 5.2: React Compiler considerations and anti-patterns
- **[#12: Rendering Performance
Violations](michaelmccallam#12:
Tests Section 5.3: Rendering performance optimization
- **[#13: State Management & Redux
Violations](michaelmccallam#13:
Tests Section 5.4: Redux and state management patterns
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Modernizes BUGBOT documentation and rule configuration.
>
> - Replaces `BUGBOT.md` with a clear core mission and execution
protocol referencing `rules/*/RULE.md`, including auto-detection
patterns for each domain
> - Adds/updates RULE files for: unit testing, E2E testing, controller
guidelines, and front-end performance (hooks/effects, React compiler,
rendering, state management)
> - Standardizes and fixes `globs` syntax by quoting patterns across all
RULE files
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
745a1e9. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
|
This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions. |
E2E BUGBOT Rule Violation Test
Purpose
This PR intentionally introduces E2E testing guideline violations to validate BUGBOT's detection capabilities for E2E-specific anti-patterns and bad practices.
These are intentional violations for testing purposes. All changes represent anti-patterns that should be caught and flagged by BUGBOT. DO NOT merge without BUGBOT verification.
Files Modified
Existing Files (5)
test/e2e/tests/settings/change-language.spec.ts- 6 violationstest/e2e/tests/transaction/send-eth.spec.js- 7 violationstest/e2e/tests/tokens/add-hide-token.spec.ts- 6 violationstest/e2e/tests/onboarding/onboarding.spec.ts- 7 violationstest/e2e/tests/settings/settings-general.spec.js- 6 violationsNew Files (1)
test/e2e/tests/network/switch-network-bad.spec.js- 11+ violations (demo file with all major violations)Documentation
.cursor/E2E_BUGBOT_VIOLATIONS_SUMMARY.md- Comprehensive violations catalogViolations Summary (40+ total)
By Category
Key Violations Introduced
Test Naming (16 violations)
TypeScript Requirement (3 violations)
Page Object Model (12 violations)
check_tokenItemNumber(File 3)checkPageIsLoaded()pattern (File 3)Prohibited Patterns (15 violations)
driver.navigate()calls (File 4)Proper Waiting (13 violations - 16 total driver.delay() calls)
Test Organization (6 violations)
Flow Objects (3 violations)
Test Reliability (3 violations)
Most Egregious Violations
switch-network-bad.spec.js) - 11 driver.delay() callsViolation Markers
All violations are marked with comments:
// E2E_BUGBOT_VIOLATION: [Category] - [Specific Rule]
Note
Intentionally injects anti-patterns across test suites to validate BUGBOT’s detection, without modifying production code.
test/e2e/tests/network/switch-network-bad.spec.jsdemonstrating multiple violations (hardcoded selectors,driver.delay, no POM/flows, no mocks)onboarding.spec.ts,settings/change-language.spec.ts,settings/settings-general.spec.js,tokens/add-hide-token.spec.ts,transaction/send-eth.spec.jsto include naming, waiting, POM, and organization violations (e.g., JS specs vs TS, direct driver calls, custom waits)ui/components/app/snaps/snap-ui-address/snap-ui-address.test.tsx,ui/components/app/transaction-list/transaction-list.test.js,ui/hooks/useAsyncResult.test.ts,ui/hooks/useTokenRatesPolling.test.ts,ui/pages/confirmations/utils/token.test.ts,ui/selectors/accounts.test.ts,ui/store/actions.test.jsScope/Risk: Test-only changes aimed at rule validation; expect flaky/slow tests by design (real network calls, improper waits).
Written by Cursor Bugbot for commit 9d366ae. This will update automatically on new commits. Configure here.