command-http
Command for http requests, implements seed data generation for test cases.
The command can be used like this:
import { Http, RequestConfig } from '../src'
...
const config: RequestConfig = { url }
const response = await new Http.Request<any>(config).execute()
Mode behavior
- cloud : returns response of the external resource (as defined via url/config)
- connected : same as cloud
- edge : same as cloud
- pure : returns local seed data (throws an error if no seed data is available)
Seed data generation
Use global switch to enable seed data generation while http request:
Http.fetchPureSeed = true
...
...
Http.fetchPureSeed = false
The seed data can be fetched in any mode except pure, as tests within the code pipeline should not call external ressources.
Configuration hooks
In case you want to modify the seed creation for a specific case, you can create a specific SeedLocalConfig by creating a TypeScript-file within the seed folder structure:
import { SeedLocalConfig } from '@seagull/commands-http/seedLocalConfig'
export default <SeedLocalConfig<SomeResponse>>{
hook: (fixture: SomeResponse) => {
return fixture
},
expiresInDays: 14,
}
A configuration file is applied for all subsequent fixtures.