Comments (6)
I do but in my experience it is not a great idea to test against a different database than the one you are running in production or trying to be smarter about bootstrapping a test database. If you are not happy with cleaning up and seeding it on every test run you can still make sure that each test cleans up its own data:
describe('\'users\' service', () => {
it('registered the service', () => {
const service = app.service('users');
expect(service).toBeTruthy();
});
it('creates a user', async () => {
const user = await app.service('users').create({
email: '[email protected]',
password: 'VerySecretP@assw0rd',
});
expect(user.password).not.toEqual('VerySecretP@assw0rd'');
await app.service('users').remove(user._id);
});
});
from docs.
This depends on the database. With NeDB yes, the most reliable way would be removing the data folder by adding shx rm -rf data/
to your test script.
from docs.
@daffl Yes I'm already doing that:
"clean": "shx rm -rf test/data/",
"jest": "npm run clean && NODE_ENV=test npm run seed && NODE_ENV=test jest --coverage --detectOpenHandles --forceExit"
But how am I supposed to deal with it when I have a single test to run?
npx jest test/services/users.test.ts
It would be great to have something that "reset" the created data of each test.
This would be the NodeJS equivalent of this great PHP tool : https://packagist.org/packages/dama/doctrine-test-bundle
from docs.
This also why I have the npm run seed
command to generate data before testing.
I would like to get rid of it and see each test load data independently and cleanup.
Linked to memory database would be the best.
Do you see my point of view?
from docs.
Yes, I will maybe do it. But this assume additional repetitive code to produce, I would like to find a more lazy way. 👍
from docs.
Imo, tests are the one place where repetitive code is ok. I've seen many a time when someone tried to be lazy and the test code became unmaintainable.
from docs.
Related Issues (20)
- Comment: Quick start (guides/basics/starting.md) HOT 2
- Comment: Writing tests (guides/basics/testing.md) HOT 1
- Comment: File uploads in FeathersJS (cookbook/express/file-uploading.md)
- How to test user related security on service? HOT 9
- A package for dart/Flutter eco system a flutter client. HOT 1
- Typescript: How to export data model typing to the Feathers client HOT 5
- Cookbook Suggestion:
- syntax highlighting isn't so colourblind / accessibility compliant HOT 5
- Comment:Readme HOT 1
- Sync user's language choice HOT 10
- Some links are broken HOT 2
- Comment:Step-Basic-Db-connector HOT 1
- [Security] Add security suggestions of $populate mongoose operator
- FR: A central place to style all Feathers docs. HOT 1
- FR: A central place to style all Feathers docs.
- PG for Postgres may give problems for top level arrays in JSONB columns
- Cookbook Suggestion: the most simple feathers example HOT 1
- Using Chat GPT HOT 1
- Helmet use is superseded by koa/cors
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.