Protractor E2E Test Seed Database

后端 未结 1 749
失恋的感觉
失恋的感觉 2021-02-04 11:34

I haven\'t found a good way of doing this so hoping someone has some ideas. Is there any way to seed the database with test data before running a E2E Protractor test?

Do

1条回答
  •  清歌不尽
    2021-02-04 12:09

    Being in a NodeJs environment, you can connect to the database directly from Protractor, but I wouldn't go down that route. You'll have to update your SQL-setup-script along with your changes to your back-end.

    There are other ways:

    1. Use your existing REST facade to populate your database - register a user, connect with another user, etc. If you set-up each of your tests with unique data you would be able to run them simultaneously that way.
    2. Expose to your test environment a special REST point that does all the clearing/setting-up for you between tests.

    You can fire REST calls directly from the Protractor environment or use your browser for that.

    0 讨论(0)
提交回复
热议问题