shared test fixture for meteor velocity cucumber and jasmine

347 Views Asked by At

How do I share a fixture between my cucumber and jasmine test?

I can create a fixture with one jasmine server integration test that can be used with other jasmine server integration tests. But (due to different "mirrors" I guess?) I cannot use the same fixture in a cucumber test. The Mongo collection does not have the data created by the jasmine server integration tests.

One option is to save the state to a flat file, or nock, something similar outside of meteor. But, it would be a lot simpler to reference a common collection (on the same mirror?) for test fixtures. Is this possible?

3

There are 3 best solutions below

2
On BEST ANSWER

You can use the package-fixture pattern for fixtures to achieve what you're asking for. See here: https://github.com/meteor-velocity/velocity#fixtures--test-data

Any packages that you create with the debugOnly flag in the package descriptor will not be bundled in production.

2
On

Everything is possible. However, I do not recommend to make tests depend on each other. As Wikipedia states:

Ideally, each test case is independent from the others.

A few reasons why your tests should be independent:

  • Easier to narrow down the problem if tests fail (if tests depend on each other you will have some test failures, where simply the predecessor did fail)
  • Allows for parallelisation to reduce total test run time (as your test suite grows)

Currently Velocity hard-codes port 5000 for the test mirror instance of your app, but I know that there are efforts to make this port configurable (which would have to be supported by the test frameworks themselves).

1
On

The summary answer to this is: shared runtime state between test tools is not supported usage (although both can execute code from the same fixture package). The usage I am going for is not a conventional pattern and involves some sort of dependency between tests.

To get what I was going for I had to write my own tool. What I wanted was basically a wrapper around nock to help me generate test fixtures by recording the results of my e2e tests with integrations turned on.