JavaScript · Cypress
Manufacturing with Cypress
A live machine dashboard with status filters and OEE meters, work orders whose bill of materials is checked against stock (shortages block release), a start → complete lifecycle, and quality inspection with tolerance-based pass/fail.
App under test
⚙️ FactoryOS
- URL
- /apps/factory
- Impeller stock
- 40 units
- QC spec
- 25.00 ± 0.05 mm …
- WO numbers
- WO-1001 …
Scenarios to automate
Work top to bottom — each one adds a new technique.
- 1
Changing data
Intermediatemachine-card data-status changes every ~4s; assert counts add up (count-*) rather than specific states.
- 2
Meters
Beginneroee-* use role=meter with aria-valuenow; avg-oee is the mean of all machines.
- 3
BOM maths
IntermediatePump × 50 → required-bearing 100, required-impeller 50 (stock 40) → shortage-impeller shows −10.
- 4
Blocked action
Intermediaterelease-wo with a shortage shows wo-error naming the part; wo-qty-dec10 clears it (materials-ok).
- 5
Lifecycle
Beginnerstart-<id> → In progress → complete-<id> → Completed; buttons change with status.
- 6
Tolerance checks
Advanced25.06 mm fails (Out of tolerance) while 25.05 passes; any defect checkbox forces FAIL.
- 7
Incomplete inspection
Beginnersubmit-inspection before all measurements shows qc-error; qc-result stays Pending.
Sample Cypress suite
A working starting point that finds elements every way Cypress can — by role, label, text, id, name, CSS, XPath and data-testid — so you practice them all. Pick your language, switch to data-testid only to compare, or try your own in the Locator Playground.
Cypress runs inside the browser, so it only supports JavaScript and TypeScript — there is no Python, Java or C# version of Cypress. For those languages, see Selenium or Playwright.
// Uses the getByTestId custom command from the Cypress setup (cypress/support/commands.js).
// Locators in this suite: cy.contains ×8 · #id ×2 · [name] ×2 · [aria-label] ×2 · getByTestId ×11
describe('FactoryOS — manufacturing', () => {
it('releases a work order and passes QC', () => {
cy.visit('/apps/factory');
cy.getByTestId('machine-grid').should('be.visible');
cy.contains('a', 'Work orders').click();
cy.getByTestId('new-work-order').click();
cy.get('#wo-product').select('pump');
cy.get('[name="wo-qty"]').type('50');
cy.getByTestId('required-impeller').should('contain', '50');
cy.getByTestId('shortage-impeller').should('contain', '−10');
cy.contains('button', 'Release work order').click();
cy.getByTestId('wo-error').should('contain', 'Impeller');
cy.getByTestId('wo-qty-dec10').click();
cy.getByTestId('materials-ok').should('be.visible');
cy.get('#wo-line').select('Line B');
cy.getByTestId('wo-due').eq(3).click();
cy.contains('button', 'Urgent').click();
cy.contains('button', 'Release work order').click();
cy.getByTestId('wo-status-WO-1001').should('contain', 'Released');
cy.contains('button', 'Start').click();
cy.contains('button', 'Complete').click();
cy.getByTestId('wo-status-WO-1001').should('contain', 'Completed');
cy.contains('a', 'Quality').click();
cy.get('[aria-label="Bore diameter measured"]').type('25.02');
cy.get('[name="qc-length"]').type('119.9');
cy.get('[aria-label="Weight measured"]').type('2.43');
cy.getByTestId('qc-result').should('contain', 'PASS');
cy.contains('button', 'Record inspection').click();
cy.getByTestId('inspection-id').should('contain', 'QC-');
});
});