Repository navigation
Disable inclusion of User.accessTokens - #1318
Conversation
There was a problem hiding this comment.
Can you please build the app in test/user.integration.js and don't use loopback-boot?
There was a problem hiding this comment.
Why? The purpose of the user.integration.js is to test a LB app's built-in user model.
There was a problem hiding this comment.
The purpose of the user.integration.js is to test a LB app's built-in user model.
As you wrote yourself, there is nothing related to loopback-boot in the scenario you are testing.
It is a good practice to write the test code in such way that it's easy to quickly understand what is the scenario being tested. The test scenario should be also as minimal as possible and include only things that are absolutely necessary for the test.
By using a fixture defined in several files living outside of the test file, you are making it difficult to understand what is exactly being tested. By including lots of unrelated stuff in your fixture, you make it difficult to see what is the important (test-specific) part and what is just boilerplate. Last but not least, all these extra unneeded bits are making the maintenance more expensive.
This is already visible in this pull request, as the server/server.js file is not following the project structure as scaffolded by recent versions of loopback-workspace.
To test the built-in user model, you need just few lines of code:
var app = loopback();
app.dataSource('db', { connector: 'memory' });
app.model(loopback.User, { dataSource: 'db' });
app.model(loopback.AccessToken, { dataSource: 'db' });
app.model(loopback.ACL, { dataSource: 'db' });
app.model(loopback.Role, { dataSource: 'db' });
app.model(loopback.RoleMapping, { dataSource: 'db' }); // this may be not necessary
app.enableAuth();
app.use(loopback.rest());
request = supertest(app);I admit this setup is not as short as it should be, let's discuss the best API in #1323 and keep the code above for the purposes of this PR.
There was a problem hiding this comment.
There are more models such as post and blog are needed. I'll merge the PR as is and defer the cleanup of tests.
There was a problem hiding this comment.
I am rather unhappy that you have added tests that always pass, regardless of whether the underlying implementation works or not. Such tests are giving false sense of security 👎
…ss-tokens Disable inclusion of User.accessTokens
/to @bajtos