forked from pankod/next-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.ts
45 lines (36 loc) · 970 Bytes
/
jest.setup.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import * as Adapter from 'enzyme-adapter-react-16';
require('enzyme').configure({ adapter: new Adapter() });
const nock = require('nock');
nock('http://localhost:3000')
.get('/api/planetary/apod')
.query({ api_key: 'NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo', hd: true })
.reply(200, {
copyright: "Pankod",
date: "2019-05-23",
explanation: "",
hdurl: "",
media_type: "",
service_version: "",
title: "",
url: ""
});
nock('http://localhost:3000')
.get('/api/planetary/apod')
.query({ api_key: 'NNKOjkoul8n1CH18TWA9gwngW1s1SmjESPjNoUFo', hd: false })
.reply(500);
nock('http://localhost:3000')
.get('/api/200')
.reply(200, { success: true });
nock('http://localhost:3000')
.get('/api/404')
.reply(404, { success: false });
//env variables
require('dotenv').config({ path: '.env.test' });
import { setConfig } from 'next/config'
setConfig({
publicRuntimeConfig:
{
'API_URL': process.env.API_URL,
'API_KEY': process.env.API_KEY
}
});