Skip to content

Modernize test infrastructure and linting toolchain - #1003

Open
maxxcrawford wants to merge 7 commits into
mainfrom
update-test-deps
Open

Modernize test infrastructure and linting toolchain#1003
maxxcrawford wants to merge 7 commits into
mainfrom
update-test-deps

Conversation

@maxxcrawford

@maxxcrawford maxxcrawford commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Our linting setup was running ESLint 4 (released 2018) and our test suite depended on webextensions-jsdom and webextensions-geckodriver, two abandoned forks. This replaces both with modern alternatives.

ESLint is upgraded to v10 with the new flat config format. The test runner moves from mocha to vitest, backed by a small custom browser mock that we own and can maintain. All 34 existing tests pass unchanged. Other outdated packages (sinon, chai, web-ext, etc.) are brought up to date and npm audit is clean.

Note - The one functional test (badging, via geckodriver) is dropped for now and should be re-added with Playwright.

Additionally, I added a setup file for CircleCI which is running the new test suite successfully. This check will run against all future PRs too.

Testing

  1. Install new node deps. There should be no npm audit warnings.
npm install
  1. Run new test suite. ESLint should run clean, and 34 tests pass.
npm test
  1. Run the dev command. A temp browser with FBC loaded should run!
npm run dev
  1. Generate a new package (after safely running tests)
npm run build

@maxxcrawford
maxxcrawford requested a review from groovecoder April 2, 2026 15:01
@maxxcrawford
maxxcrawford force-pushed the update-test-deps branch 2 times, most recently from 4cd8bd2 to b1286e4 Compare April 2, 2026 17:04
Drops the geckodriver functional test (test/functional/badging.test.js) as webextensions-geckodriver is abandoned. This test should be re-added using Playwright.

Fixes #1002
Re-implements the functional test that was lost when geckodriver was removed (#1002). Uses Playwright + Firefox to verify the content script badges [data-login-with-facebook] elements on a fixture page. Adds a minimal static server, browser polyfill, and CircleCI job.

Fixes #1004
…ntion

Adds two Playwright tests covering the remaining patternDetection paths:
one verifies login, share, and passive-share elements each get the correct badge class;
another confirms the fbc-has-badge guard prevents an element from being badged more than once.

Fixes #1006
web-ext resolves the firefox alias via mdfind bundle ID lookup, which returns both Release and Beta since they share org.mozilla.firefox — alphabetical ordering causes Beta to win. Adds a gitignored local config and example template so developers can pin a specific binary.

Fixes #1013
@eslint/js 10's recommended config enables no-useless-assignment, which
flags a dead assignment in addHeaderWithBackArrow: the return value of
addHeader() was immediately overwritten. The call is kept for its side
effect of appending the header to the fragment; only the discarded
binding is removed.
Comment thread src/panel.js
let el = addHeader(fragment);
el = document.createElement("button");
addHeader(fragment);
const el = document.createElement("button");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is the only change to the actual extension code.

It was necessary to get ESLlint to v10 without any rule overrides

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (non-blocking): the PR description seems out-dated. it says the functional badging test is dropped and should be restored with playwright. This looks like the badging tests in playwright?

question (blocking): the old tests drove real Firefox thru geckodriver and loaded the extension at a moz-extension:// URL. this new test serves fixtures and stubs window.browser so would this test actually catch something like a failure to inject the content script, or a bug where injecting the content script breaks something on the page? that seems like the kind of bug that could really break users' experience.

it seems like we're replacing 2 abandoned forks of projects that drove a real browser with this new mock. might be the right thing to do, but it also means future green check-marks mean less about real browser behavior than old ones did. if we're still sending FBC releases thru full QA cycles that's fine. but let's not merge this until we're confident in the answer here.

Comment thread package.json
"test-functional-dev": "cross-env NODE_ENV=development npm run test-functional",
"coverage": "nyc --reporter=html --reporter=text mocha --reporter=progress test/setup.js test/features/*.test.js --timeout 60000",
"test": "npm run test:lint && npm run test:unit",
"test:lint": "eslint src test/features",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (non-blocking): this no longer lints the test/functional/ directory - is that intentional?

const onCompletedListeners = [];
const onErrorOccurredListeners = [];

function makeListener() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (non-blocking): is this ever actually called?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants