Skip to content

How to setup E2E tests

Wojtek Cichoń edited this page Jan 25, 2021 · 2 revisions

Mudita Center uses Spectron as an E2E testing tool. The app requires additional setup with the Pure phone. To write E2E tests for Mudita Center please follow these steps:

1. Create file in src/tests with .e2e.ts extension.

2. Add Jest globals to start and close the app after each test.

let app: any

beforeEach(async () => {
  app = await startApp()
})

afterEach(async () => {
  await stopApp(app)
})

If tests need to reach part of the app where the phone connection is needed, an additional configuration has to be added. The first parameter has to be passed to the startApp function. It will make sure we can reach parts of the app's restricted apps state when the phone is connected. Additionally, we await some part of the menu just to make sure the page is loaded before we move onto appropriate test steps.

let app: any

beforeEach(async () => {
  app = await startApp(true)
  await enablePhoneSimulation(app)
  await app.client.waitUntil(() =>
    app.client.$(`*[data-testid=${MenuGroupTestIds.Contacts}]`).isVisible()
  )
})

afterEach(async () => {
  await stopApp(app)
})