Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 46a6e23

Browse files
committed
update testing documentation with new api
1 parent ab0909c commit 46a6e23

File tree

7 files changed

+26
-47
lines changed

7 files changed

+26
-47
lines changed

Diff for: en/guide/development-tools.md

+8-11
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,23 @@ We add our test file `test/index.test.js`:
6464

6565
```js
6666
import test from 'ava'
67-
import Nuxt from 'nuxt'
67+
import { Nuxt, Builder } from 'nuxt'
6868
import { resolve } from 'path'
6969

70-
// We keep the nuxt and server instance
71-
// So we can close them at the end of the test
70+
// We keep a reference to nuxt so we can close
71+
// the server at the end of the test
7272
let nuxt = null
73-
let server = null
7473

75-
// Init Nuxt.js and create a server listening on localhost:4000
74+
// Init Nuxt.js and start listening on localhost:4000
7675
test.before('Init Nuxt.js', async t => {
7776
const rootDir = resolve(__dirname, '..')
7877
let config = {}
7978
try { config = require(resolve(rootDir, 'nuxt.config.js')) } catch (e) {}
8079
config.rootDir = rootDir // project folder
8180
config.dev = false // production build
8281
nuxt = new Nuxt(config)
83-
await nuxt.build()
84-
server = new nuxt.Server(nuxt)
85-
server.listen(4000, 'localhost')
82+
await new Builder(nuxt).build()
83+
nuxt.listen(4000, 'localhost')
8684
})
8785

8886
// Example of testing only generated html
@@ -102,9 +100,8 @@ test('Route / exits and render HTML with CSS applied', async t => {
102100
t.is(window.getComputedStyle(element).color, 'red')
103101
})
104102

105-
// Close server and ask nuxt to stop listening to file changes
106-
test.after('Closing server and nuxt.js', t => {
107-
server.close()
103+
// Close the nuxt server
104+
test.after('Closing server', t => {
108105
nuxt.close()
109106
})
110107
```

Diff for: es/guide/development-tools.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ We add our test file `test/index.test.js`:
6464

6565
```js
6666
import test from 'ava'
67-
import Nuxt from 'nuxt'
67+
import { Nuxt, Builder } from 'nuxt'
6868
import { resolve } from 'path'
6969

7070
// We keep the nuxt and server instance
7171
// So we can close them at the end of the test
7272
let nuxt = null
73-
let server = null
7473

7574
// Init Nuxt.js and create a server listening on localhost:4000
7675
test.before('Init Nuxt.js', async t => {
@@ -80,9 +79,8 @@ test.before('Init Nuxt.js', async t => {
8079
config.rootDir = rootDir // project folder
8180
config.dev = false // production build
8281
nuxt = new Nuxt(config)
83-
await nuxt.build()
84-
server = new nuxt.Server(nuxt)
85-
server.listen(4000, 'localhost')
82+
await new Builder(nuxt).build()
83+
nuxt.listen(4000, 'localhost')
8684
})
8785

8886
// Example of testing only generated html
@@ -104,7 +102,6 @@ test('Route / exits and render HTML with CSS applied', async t => {
104102

105103
// Close server and ask nuxt to stop listening to file changes
106104
test.after('Closing server and nuxt.js', t => {
107-
server.close()
108105
nuxt.close()
109106
})
110107
```

Diff for: fr/guide/development-tools.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,12 @@ Nous ajoutons notre fichier de test `test/index.test.js`:
6464

6565
```js
6666
import test from 'ava'
67-
import Nuxt from 'nuxt'
67+
import { Nuxt, Builder } from 'nuxt'
6868
import { resolve } from 'path'
6969

7070
// We keep the nuxt and server instance
7171
// So we can close them at the end of the test
7272
let nuxt = null
73-
let server = null
7473

7574
// Init Nuxt.js and create a server listening on localhost:4000
7675
test.before('Init Nuxt.js', async t => {
@@ -80,9 +79,8 @@ test.before('Init Nuxt.js', async t => {
8079
config.rootDir = rootDir // project folder
8180
config.dev = false // production build
8281
nuxt = new Nuxt(config)
83-
await nuxt.build()
84-
server = new nuxt.Server(nuxt)
85-
server.listen(4000, 'localhost')
82+
await new Builder(nuxt).build()
83+
nuxt.listen(4000, 'localhost')
8684
})
8785

8886
// Example of testing only generated html
@@ -104,7 +102,6 @@ test('Route / exits and render HTML with CSS applied', async t => {
104102

105103
// Close server and ask nuxt to stop listening to file changes
106104
test.after('Closing server and nuxt.js', t => {
107-
server.close()
108105
nuxt.close()
109106
})
110107
```

Diff for: ja/guide/development-tools.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ export default {
6767

6868
```js
6969
import test from 'ava'
70-
import Nuxt from 'nuxt'
70+
import { Nuxt, Builder } from 'nuxt'
7171
import { resolve } from 'path'
7272

7373
// nuxt と server インスタンスを保持します
7474
// そうすればテスト終了時にそれらをクローズできます
7575
let nuxt = null
76-
let server = null
7776

7877
// Nuxt.js を初期化し localhost:4000 でリスニングするサーバーを作成します
7978
test.before('Init Nuxt.js', async t => {
@@ -83,9 +82,8 @@ test.before('Init Nuxt.js', async t => {
8382
config.rootDir = rootDir // project folder
8483
config.dev = false // production build
8584
nuxt = new Nuxt(config)
86-
await nuxt.build()
87-
server = new nuxt.Server(nuxt)
88-
server.listen(4000, 'localhost')
85+
await new Builder(nuxt).build()
86+
nuxt.listen(4000, 'localhost')
8987
})
9088

9189
// 生成された HTML のみをテストする例
@@ -107,7 +105,6 @@ test('Route / exits and render HTML with CSS applied', async t => {
107105

108106
// サーバーを閉じて nuxt にファイル更新のリスニングを中止させる
109107
test.after('Closing server and nuxt.js', t => {
110-
server.close()
111108
nuxt.close()
112109
})
113110
```

Diff for: ko/guide/development-tools.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ export default {
6666

6767
```js
6868
import test from 'ava'
69-
import Nuxt from 'nuxt'
69+
import { Nuxt, Builder } from 'nuxt'
7070
import { resolve } from 'path'
7171

7272
// nuxt 와 server 인스턴스를 여기에 확보해둡니다.
7373
// 그러면 테스트가 종료되었을 때 이것들을 close할 수 있습니다.
7474
let nuxt = null
75-
let server = null
7675

7776
// Nuxt.js 를 초기화하고 localhost:4000 에서 리스닝하는 서버를 작성합니다.
7877
test.before('Init Nuxt.js', async t => {
@@ -82,9 +81,8 @@ test.before('Init Nuxt.js', async t => {
8281
config.rootDir = rootDir // project folder
8382
config.dev = false // production build
8483
nuxt = new Nuxt(config)
85-
await nuxt.build()
86-
server = new nuxt.Server(nuxt)
87-
server.listen(4000, 'localhost')
84+
await new Builder(nuxt).build()
85+
nuxt.listen(4000, 'localhost')
8886
})
8987

9088
// 생성된 HTML 만을 테스트하는 예제
@@ -106,7 +104,6 @@ test('Route / exits and render HTML with CSS applied', async t => {
106104

107105
// 서버를 닫고 nuxt 에 파일갱신 리스닝을 중지시킨다
108106
test.after('Closing server and nuxt.js', t => {
109-
server.close()
110107
nuxt.close()
111108
})
112109
```

Diff for: ru/guide/unit-testing.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,12 @@ export default {
5454

5555
```js
5656
import test from 'ava'
57-
import Nuxt from 'nuxt'
57+
import { Nuxt, Builder } from 'nuxt'
5858
import { resolve } from 'path'
5959

6060
// Сохраним экземпляры nuxt и server.
6161
// Мы сможем сбросить их в конце теста.
6262
let nuxt = null
63-
let server = null
6463

6564
// Инициализируем Nuxt.js и создадим сервер по адресу localhost:4000
6665
test.before('Init Nuxt.js', async t => {
@@ -70,9 +69,8 @@ test.before('Init Nuxt.js', async t => {
7069
config.rootDir = rootDir // папка проекта
7170
config.dev = false // финальная сборка
7271
nuxt = new Nuxt(config)
73-
await nuxt.build()
74-
server = new nuxt.Server(nuxt)
75-
server.listen(4000, 'localhost')
72+
await new Builder(nuxt).build()
73+
nuxt.listen(4000, 'localhost')
7674
})
7775

7876
// Пример генерации html-кода только для этого теста
@@ -94,7 +92,6 @@ test('Route / exits and render HTML with CSS applied', async t => {
9492

9593
// Остановить сервер и попросить nuxt не отслеживать изменения файлов
9694
test.after('Closing server and nuxt.js', t => {
97-
server.close()
9895
nuxt.close()
9996
})
10097
```

Diff for: zh/guide/development-tools.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@ export default {
6767

6868
```js
6969
import test from 'ava'
70-
import Nuxt from 'nuxt'
70+
import { Nuxt, Builder } from 'nuxt'
7171
import { resolve } from 'path'
7272

7373
// 我们用两个变量保留 nuxt 和 server 实例的引用
7474
// 这样可以在单元测试结束之后关掉它们
7575
let nuxt = null
76-
let server = null
7776

7877
// 初始化 Nuxt.js 并创建一个监听 localhost:4000 的服务器
7978
test.before('Init Nuxt.js', async t => {
@@ -83,9 +82,8 @@ test.before('Init Nuxt.js', async t => {
8382
config.rootDir = rootDir // 项目目录
8483
config.dev = false // 生产构建模式
8584
nuxt = new Nuxt(config)
86-
await nuxt.build()
87-
server = new nuxt.Server(nuxt)
88-
server.listen(4000, 'localhost')
85+
await new Builder(nuxt).build()
86+
nuxt.listen(4000, 'localhost')
8987
})
9088

9189
// 测试生成的html
@@ -107,7 +105,6 @@ test('路由 / 有效且渲染的HTML有特定的CSS样式', async t => {
107105

108106
// 关掉服务器和Nuxt实例,停止文件监听。
109107
test.after('Closing server and nuxt.js', t => {
110-
server.close()
111108
nuxt.close()
112109
})
113110
```

0 commit comments

Comments
 (0)