Replies: 1 comment 1 reply
-
For this third party service I guess they have a healthCheck endPoint, which you can place it in a helper function to get the status . const res = await client.get('/accounts')
.set('Authorization', 'Bearer ' + token)
.expect(200); And the helper function inside its own file can be like: import axios from 'axios';
export async function givenTokenFromStrapiDirectly () {
const { data } = await axios.post('http://localhost:1337/auth/local', {
identifier: 'youridentifier',
password: 'yourpassword',
});
return data.token;
} The givenTokenFromStrapiDirectly should be invoked like so: before('setupApplication', async () => {
({app, client} = await setupApplication());
token = await givenTokenFromStrapiDirectly();
});
Well, that's more or less the logic. Also I encourage you to read the loopback tests and the shopping example application to learn more about how to leverage the test suite at loopback4. |
Beta Was this translation helpful? Give feedback.
-
Hello guys, How to test if the datasource rest link is down? I have created a datasource like strapi api. i wanna put on my unit test it strapi api is down.
and since the endpoint is can access only when user is login needed to be authenticated how to bypass authentication. the authentication is coming from another 3rd party api. what the lb4 application is getting the Bearer token and validate it.
i already tried to use invoke but of course since in my controller i injected authentication it gives me
here's my sample code
Beta Was this translation helpful? Give feedback.
All reactions