mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
API Integration Tests via jest (#10899)
* tests: experiment with api tests * api tests are getting nice * api: api testing ready for feedback
This commit is contained in:
30
tests/api/client.ts
Normal file
30
tests/api/client.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
const axios = require('axios');
|
||||
|
||||
export function getClient(options) {
|
||||
return axios.create({
|
||||
baseURL: 'http://localhost:3000',
|
||||
timeout: 1000,
|
||||
auth: {
|
||||
username: options.username,
|
||||
password: options.password,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function getAdminClient() {
|
||||
return getClient({
|
||||
username: 'admin',
|
||||
password: 'admin',
|
||||
});
|
||||
}
|
||||
|
||||
let client = getAdminClient();
|
||||
|
||||
client.callAs = function(user) {
|
||||
return getClient({
|
||||
username: user.login,
|
||||
password: 'password',
|
||||
});
|
||||
};
|
||||
|
||||
export default client;
|
||||
Reference in New Issue
Block a user