File tree Expand file tree Collapse file tree 6 files changed +49
-18
lines changed Expand file tree Collapse file tree 6 files changed +49
-18
lines changed Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` module dev mode admin 1` ] = `
4
+ "<!DOCTYPE html>
5
+ <html >
6
+ <head >
7
+ <meta charset =\\"utf-8\\" />
8
+ <meta name =\\"viewport\\" content =\\"width=device-width, initial-scale =1.0\\" />
9
+ <link href =\\"/admin/config.yml\\" type =\\"text/yaml\\" rel =\\"cms-config-url\\">
10
+ <title>Content Manager</title>
11
+ </head>
12
+ <body>
13
+ <script type =\\"text/javascript\\" src =\\"/admin/bundle.d1e28a1f3d3e1d943036.js\\"></script></body>
14
+ </html>
15
+ "
16
+ `;
Original file line number Diff line number Diff line change @@ -3,10 +3,14 @@ jest.mock("../src/utils/yaml");
3
3
4
4
import { get , commonBefore , commonAfter } from "./nuxt" ;
5
5
6
- describe ( "config" , ( ) => {
7
- beforeAll ( commonBefore ( ) ) ;
6
+ describe ( "config" , async ( ) => {
7
+ beforeAll ( async ( ) => {
8
+ await commonBefore ( ) ( ) ;
9
+ } ) ;
8
10
9
- afterAll ( commonAfter ) ;
11
+ afterAll ( async ( ) => {
12
+ await commonAfter ( ) ;
13
+ } ) ;
10
14
11
15
test ( "netlify-cms.yml" , async ( ) => {
12
16
const config = await get ( "/admin/config.yml" ) ;
Original file line number Diff line number Diff line change 1
1
import { get , commonBefore , commonAfter } from "./nuxt" ;
2
2
3
- describe ( "module dev mode" , ( ) => {
4
- beforeAll ( commonBefore ( { dev : true } ) ) ;
3
+ describe ( "module dev mode" , async ( ) => {
4
+ beforeAll ( async ( ) => {
5
+ await commonBefore ( { dev : true } ) ( ) ;
6
+ } ) ;
5
7
6
- afterAll ( commonAfter ) ;
8
+ afterAll ( async ( ) => {
9
+ await commonAfter ( ) ;
10
+ } ) ;
7
11
8
12
test ( "render" , async ( ) => {
9
13
const html = await get ( "/" ) ;
@@ -12,6 +16,6 @@ describe("module dev mode", () => {
12
16
13
17
test ( "admin" , async ( ) => {
14
18
const html = await get ( "/admin/" ) ;
15
- expect ( html ) . toMatch ( / . * < s c r i p t [ \s \S ] * ? > [ \s \S ] * ? < \/ s c r i p t > < \/ b o d y > / ) ;
19
+ expect ( html ) . toMatchSnapshot ( ) ;
16
20
} ) ;
17
21
} ) ;
Original file line number Diff line number Diff line change 1
1
import { get , generate , generateAfter } from "./nuxt" ;
2
2
3
- describe ( "module dev mode" , ( ) => {
4
- beforeAll ( generate ( ) ) ;
3
+ describe ( "module generate mode" , async ( ) => {
4
+ beforeAll ( async ( ) => {
5
+ await generate ( ) ( ) ;
6
+ } ) ;
5
7
6
- afterAll ( generateAfter ) ;
8
+ afterAll ( async ( ) => {
9
+ await generateAfter ( ) ;
10
+ } ) ;
7
11
8
12
test ( "admin" , async ( ) => {
9
13
const html = await get ( "/admin/" ) ;
10
- expect ( html ) . toMatch ( / . * < s c r i p t [ \s \S ] * ? > [ \s \S ] * ? < \/ s c r i p t > < \/ b o d y > / ) ;
14
+ expect ( html ) . toMatchSnapshot ( ) ;
11
15
} ) ;
12
16
} ) ;
Original file line number Diff line number Diff line change 1
1
import { get , commonBefore , commonAfter } from "./nuxt" ;
2
2
3
- describe ( "module" , ( ) => {
4
- beforeAll ( commonBefore ( ) ) ;
3
+ describe ( "module" , async ( ) => {
4
+ beforeAll ( async ( ) => {
5
+ await commonBefore ( ) ( ) ;
6
+ } ) ;
5
7
6
- afterAll ( commonAfter ) ;
8
+ afterAll ( async ( ) => {
9
+ await commonAfter ( ) ;
10
+ } ) ;
7
11
8
12
test ( "render" , async ( ) => {
9
13
const html = await get ( "/" ) ;
Original file line number Diff line number Diff line change 1
- import { join } from "path" ;
2
-
3
1
import { Nuxt , Builder , Generator } from "nuxt" ;
4
2
import request from "request-promise-native" ;
5
3
import Koa from "koa" ;
@@ -15,12 +13,13 @@ const url = path => `http://localhost:${process.env.PORT}${path}`;
15
13
const get = path => request ( url ( path ) ) ;
16
14
17
15
let nuxt ;
16
+ let generator ;
18
17
let server ;
19
18
20
19
const serve = ( ) => {
21
20
const app = new Koa ( ) ;
22
21
23
- app . use ( serveStatic ( join ( nuxt . options . buildDir , "dist" ) ) ) ;
22
+ app . use ( serveStatic ( generator . distPath ) ) ;
24
23
server = app . listen ( process . env . PORT ) ;
25
24
} ;
26
25
@@ -54,7 +53,7 @@ const generate = (config = {}) => async () => {
54
53
// Build a fresh nuxt
55
54
nuxt = new Nuxt ( mergedConfig ) ;
56
55
const builder = new Builder ( nuxt ) ;
57
- const generator = new Generator ( nuxt , builder ) ;
56
+ generator = new Generator ( nuxt , builder ) ;
58
57
await generator . generate ( ) ;
59
58
serve ( ) ;
60
59
} ;
You can’t perform that action at this time.
0 commit comments