How to create test data for my test scenario via cypress and cucumber

Hey there!

I have been picking up Meteor again and I am currently sifting through a lot of blog posts and such regarding test driven development via e2e-tests. So far I am pretty happy with cypress and cypress-cucumber-preprocessor. Especially because now I am testing my App from the outside. But because of this I am now stuck at creating test related database entries.

Suppose I have the following feature test:

Feature: Login
  Background:
    Given an activated user "stefanie" with password "123456"
    And an unactivated user "martin" with password "123456"

  @focus
  Scenario: User unknown
    When I visit the homepage
    And I login with "markus" and "123456"
    Then I see "Dieser Benutzername ist unbekannt"

How would you create the user from the feature step definition:

import { Given } from "cypress-cucumber-preprocessor/steps";

Given(
  "an activated user {string} with password {string}",
  (username, password) => {
    cy.log("create", username, password);
  }
);

I see two options:

  • Connect via DDP and call a Meteor method that only exists in the isTest environment
  • Somehow invoke JS code on the server

The problem is, I do not know which option to choose and how to perform these actions in the proper Meteor way…

Any hint would be most welcome! Thanks!