New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Authentication strategy 'local' is not registered" when using supertest #667
Comments
Maybe this issue belongs to feathers-authentication, but I believe this is a timing issue native to feathers as a whole. It seems that the app starts listening before it has fully initialized. |
If you don't call |
Thank you. That was the issue. I assumed that const supertest = require('supertest');
const app = require('../../src/app');
const config = require('../../config/default.json');
const testUser = {
email: 'test@test.com',
password: 'password1234',
};
describe('POST /authentication', () => {
let server;
beforeEach(done => {
// start the app
server = app.listen(0, done);
});
beforeEach(() => {
// delete all users then create the test user
return app.service('users').remove(null)
.then(() => app.service('users').create(Object.assign({}, testUser)));
});
afterEach(() => {
// delete all users
return app.service('users').remove(null);
});
afterEach(done => {
// stop the app
server.close(done);
});
it('creates a valid JWT', () => {
return supertest(server)
.post('/authentication')
.type('json')
.send(Object.assign({strategy: 'local'}, testUser))
.expect(201)
.then(res => {
return app.passport.verifyJWT(res.body.accessToken, {
secret: config.authentication.secret,
});
});
});
}); |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs. |
Steps to reproduce
Create a new feathers app with authentication using the CLI.
# use the default value for each prompt feathers g app feathers g authentication
Install
supertest
as a dev dependency.Add the following file at
test/services/authentication.test.js
:Run the test.
npm test
Expected behavior
The test should pass.
Actual behavior
The test fails with the following output:
System configuration
Module versions:
NodeJS version: v6.11.2
The text was updated successfully, but these errors were encountered: