Introducing django-cypress v1

Stavros Panakakis
Stavros Panakakis
Tech Lead
ยท2 min read
Introducing django-cypress v1

We are happy to announce the launch of django-cypress v1!

The Story Behind It

With a team background in Laravel, we were used to having a great tool called laracasts/cypress. However, we realized there was a missing piece in the Django ecosystem. So we decided to build it ourselves.

Current Features

cy.migrate()

Running database migrations is a critical part of any Django project. With cy.migrate(), you can handle migrations within your tests. It ensures that your database is in the right state for your tests and removes the interference from the previous runs.

describe('complex test case', () => {
  before(() => {
    cy.migrate(); // Run the migrations before the test case
  })

  // tests
})

cy.refreshDatabase()

The command cy.refreshDatabase() takes care of clearing the database, providing a clean and consistent state before you run your tests.

describe('complex test case', () => {
  beforeEach(() => {
    cy.refreshDatabase(); // Clear the database before each test
  })

  // tests
})

cy.manage()

Executing ./manage.py commands directly within your Cypress tests is now possible by running cy.manage(). This opens up opportunities for complex backend operations, interaction with Django APIs, and access to Django-specific functionality during test execution.

describe('complex test case', () => {
  // do some complex tasks

  // rebuild the search index of ElasticSearch
  cy.manage('search_index', ['--rebuild', '-f']); // Clear the database before each test

  // do some other complex tasks
})

Next steps

We're committed to improving django-cypress further. Our next steps include adding more commands to help the Django community in their testing journey.

How to get started

To get started, check out the django-cypress repository.

We can't wait hearing your feedback!

Share it:

facebooktwitterlinkedin