check_circle Jest Tests
Loading Jest results...
Quality, in the open
Every push runs the unit suite, a real-browser flow suite and a coverage gate before a build reaches production. What you see here is the actual output of the last run, plus a suite you can execute in your own browser right now.
Fourteen checks execute against this very page: DOM, accessibility, i18n, network and timing. Nothing is mocked and nothing is cached.
Executes client-side smoke, DOM structure, A11y, and performance tests directly in your browser.
Numbers straight from GitHub Actions. Jest results ship with the build; the Puppeteer summary is fetched live from a Gist the pipeline updates on every run.
Loading Jest results...
Loading E2E results...
Loading coverage...
Four layers, four tools. Each excerpt is taken straight from this repository.
test('closes mobile menu when a nav link is clicked', async () => {
const { container } = render(
<MemoryRouter>
<Navbar />
</MemoryRouter>
);
const toggle = screen.getByLabelText('Toggle navigation');
const menu = container.querySelector('#mobileMenu');
fireEvent.click(toggle);
expect(toggle).toHaveAttribute('aria-expanded', 'true');
expect(menu).toHaveClass('active');
fireEvent.click(screen.getByText(/Personal Projects/i));
await waitFor(() => {
expect(toggle).toHaveAttribute('aria-expanded', 'false');
expect(menu).not.toHaveClass('active');
});
});it('should NOT contain unsafe-inline in script-src', () => {
const headers = fs.readFileSync(headersPath, 'utf-8');
const cspLine = headers.match(/Content-Security-Policy:.*$/m);
expect(cspLine).toBeTruthy();
const scriptSrc = cspLine[0].match(/script-src ([^;]+)/)[1];
expect(scriptSrc).not.toContain("'unsafe-inline'");
});
it('should generate correct SHA-256 hash for JSON-LD script', () => {
const html = fs.readFileSync(htmlPath, 'utf-8');
const [, scriptContent] = html.match(
/<script type="application\/ld\+json">([\s\S]*?)<\/script>/
);
const calculatedHash = crypto
.createHash('sha256')
.update(scriptContent)
.digest('base64');
const hashes = JSON.parse(fs.readFileSync(hashesPath, 'utf-8'));
expect(hashes.jsonLd).toBe(`'sha256-${calculatedHash}'`);
});{
name: 'Cookie consent accept hides banner and stores consent',
run: async (page, step) => {
await step('Navigate to home page', () =>
page.goto(BASE_URL, { waitUntil: 'networkidle2', timeout: NAV_TIMEOUT })
);
await step('Cookie banner is shown', () =>
page.waitForSelector('#cookieConsentBanner', { timeout: NAV_TIMEOUT })
);
await step('Click "Accept all cookies"', () => page.click('#acceptCookies'));
await step('Banner is dismissed', () =>
page.waitForSelector('#cookieConsentBanner', { hidden: true, timeout: NAV_TIMEOUT })
);
await step('Consent cookie is stored', async () => {
const cookie = await page.evaluate(() => document.cookie);
assert(/cookie_consent=accepted/.test(cookie), `Consent cookie not set: "${cookie}"`);
});
},
},{
id: 'dom-safe-links',
nameKey: 'testDashboard.runner.tests.safeLinks.name',
run: async () => {
const externalLinks = Array.from(document.querySelectorAll('a[target="_blank"]'));
const insecureLinks = externalLinks.filter((link) => {
const rel = (link.getAttribute('rel') || '').toLowerCase();
return !rel.includes('noopener') && !rel.includes('noreferrer');
});
if (insecureLinks.length > 0) {
const hrefs = insecureLinks
.slice(0, 3)
.map((l) => l.getAttribute('href'))
.join(', ');
throw new Error(
`Found ${insecureLinks.length} external link(s) without rel="noopener noreferrer": ${hrefs}`
);
}
return {
message: `Verified ${externalLinks.length} external link(s) have secure rel attributes.`,
};
},
},Static HTML reports, regenerated on every deploy.