DEV Community

[Comment from a deleted post]
Collapse
 
edevil profile image
André Cruz

How do you integrate the JavaScript build pipeline in the normal Django development workflow?

Collapse
 
valentinogagliardi profile image
Valentino Gagliardi

My development workflow is: write a test - watch it fail - write the code.

In brief I build the bundle with webpack within Cypress. This is a sample of a test:

describe("App", () => {
  const password = "cypresstesting";
  before(() => {
    cy.exec("npm run dev");
  });
  it("shows a title", () => {
    cy.visit("http://127.0.0.1:8000");
    cy.title().should("include", "Valentino G.");
  });

  it("can see", () => {
    cy.viewport(1920, 1080);
    cy.get("body > nav > div.navbar-menu.is-active > div > div > a").click();
    cy
      .get('input[name="username"]')
      .type("valentino")
      .should("have.value", "valentino");
    cy
      .get('input[name="password"]')
      .type(password)
      .should("have.value", password);

    cy.get('input[type="submit"]').click();

    cy
      .get("#app > div > div.column.is-2 > aside > ul:nth-child(2) > li > a")
      .click();
    cy.get(".table");

    cy
      .get("#app > div > div.column.is-2 > aside > ul:nth-child(4) > li > a")
      .click();
    cy.get(".table");
  });
});