https://github.com/mhio/taxios
Testing apps with axios
https://github.com/mhio/taxios
Last synced: 2 months ago
JSON representation
Testing apps with axios
- Host: GitHub
- URL: https://github.com/mhio/taxios
- Owner: mhio
- Created: 2020-11-09T08:46:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-22T04:58:28.000Z (about 3 years ago)
- Last Synced: 2025-03-18T15:07:20.211Z (3 months ago)
- Language: JavaScript
- Size: 435 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# taxios
Testing made easier with axios.
If your app can inject a pino logger, mocha can dump more app context on errors.```
const { App } = require('../lib/App')
const { Taxios } = require('taxios')describe('test the app', function(){
let request
beforeEach(async function(){
const logger = Taxios.logger()
const app = await App.setup({ logger })
request = await Taxios.app(app, logger)
})afterEach(async function(){
// Get some error context from your app, if it uses the logger
request.handleMochaError(this)
// Close down the server
await request.cleanUp()
})// Or both steps in one
afterEach(async function(){
await request.afterMocha(this)
})it('should request from the app for great success', async function(){
const res = request.send('get', '/whatever', {}, { headers: { type: 'yeet' } })
expect( res.data ).to.containSubset({
yote: true
})
})})
```