Switch branches/tags
1.1.5 1.2.0 add-codepen-recipe-40 add-collect-node-env-variables cy-3.1.0-for-190 cy-task-recipe cypress-4 file-upload-recipe-43 greenkeeper/chalk-2.3.1 greenkeeper/chalk-2.3.2 greenkeeper/chalk-2.4.0 greenkeeper/chalk-pin-2.3.0 greenkeeper/enzyme-3.3.0 greenkeeper/enzyme-pin-3.2.0 greenkeeper/eslint-4.19.1 greenkeeper/jquery-3.3.1 greenkeeper/jquery-pin-3.3.0 greenkeeper/lodash-4.17.5 greenkeeper/lodash-pin-4.17.4 greenkeeper/nodemon-1.17.3 greenkeeper/nodemon-1.17.5 greenkeeper/pretty-ms-3.2.0 greenkeeper/pretty-ms-pin-3.1.0 greenkeeper/react-dom-16.1.0 greenkeeper/react-dom-16.1.1 greenkeeper/react-dom-16.2.0 greenkeeper/react-dom-pin-16.0.0 greenkeeper/@types/mocha-5.2.1 greenkeeper/webpack-4.6.0 greenkeeper/webpack-4.8.2 greenkeeper/webpack-4.8.3 greenkeeper/webpack-4.9.0 greenkeeper/webpack-4.9.1 greenkeeper/webpack-4.9.2 greenkeeper/webpack-4.10.0 greenkeeper/webpack-4.10.1 greenkeeper/webpack-4.10.2 image-with-ff issue-20 issue-30 issue-35 issue-150 issue-165 kill-background-travis-jobs-156 lint-ts master new-window-stub-recipe parallel-circle-jobs-56 parcel-preprocessor polyfill-fetch-in-test-only preprocessor property-assertion-example renovate/chai-4.x renovate/cypress-browserify-preprocessor-1.x renovate/eslint-plugin-mocha-5.x renovate/execa-0.x renovate/fs-extra-7.x renovate/json-server-0.x renovate/nodemon-1.x renovate/npm-run-all-4.x renovate/stop-only-1.x renovate/stop-only-2.x renovate/ts-loader-4.x renovate/tslint-5.x renovate/typescript-3.x renovate/webpack-4.x snapshot-testing-recipe-66 split-long-spec split-travis-ci-jobs-71 spy-retry stop-server-better-156 testing-redux-store ts-loader-4 update-ts-webpack-example vue-example-39
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
cypress
server
.babelrc
.gitignore
README.md
cypress.json
index.html
package.json

README.md

Seeding Your Database in Node

This recipe demonstrates two things:

  • Seeding your database with node.js using cy.task()
  • Using ES modules import/export syntax in your plugins

Seeding your database

If you use Node.js for your app, you can re-use your app code to help set up and manipulate data for your tests. In this example, we utilize cy.task() to connect with node via the pluginsFile to re-use the server/db.js and seed the database.

Using ES modules in plugins

You can not use import/export directly in your pluginsFile, but you can wrap it so that any subsequently required files can utilize import/export and any other syntax that is configured in your .babelrc.