|
1 | 1 | import { endent } from '@dword-design/functions'
|
2 | 2 | import tester from '@dword-design/tester'
|
| 3 | +import testerPluginNuxtConfig from '@dword-design/tester-plugin-nuxt-config' |
3 | 4 | import testerPluginPuppeteer from '@dword-design/tester-plugin-puppeteer'
|
4 |
| -import testerPluginTmpDir from '@dword-design/tester-plugin-tmp-dir' |
5 |
| -import packageName from 'depcheck-package-name' |
6 |
| -import { execa, execaCommand } from 'execa' |
7 |
| -import fs from 'fs-extra' |
8 |
| -import { Builder, Nuxt } from 'nuxt' |
9 |
| -import outputFiles from 'output-files' |
10 |
| -import { pEvent } from 'p-event' |
11 |
| -import P from 'path' |
12 |
| -import kill from 'tree-kill-promise' |
13 | 5 |
|
14 | 6 | export default tester(
|
15 | 7 | {
|
16 | 8 | nuxt3: {
|
| 9 | + config: { |
| 10 | + modules: ['./modules/foo', './modules/bar'], |
| 11 | + }, |
17 | 12 | files: {
|
18 | 13 | modules: {
|
19 | 14 | bar: {
|
@@ -48,16 +43,16 @@ export default tester(
|
48 | 43 |
|
49 | 44 | `,
|
50 | 45 | },
|
51 |
| - nuxtConfig: { |
52 |
| - modules: ['./modules/foo', './modules/bar'], |
53 |
| - }, |
54 | 46 | nuxtVersion: 3,
|
55 | 47 | async test() {
|
56 | 48 | await this.page.goto('http://localhost:3000')
|
57 | 49 | await this.page.waitForSelector('.bar')
|
58 | 50 | },
|
59 | 51 | },
|
60 | 52 | works: {
|
| 53 | + config: { |
| 54 | + modules: ['~/modules/foo', '~/modules/bar'], |
| 55 | + }, |
61 | 56 | files: {
|
62 | 57 | modules: {
|
63 | 58 | bar: {
|
@@ -92,74 +87,11 @@ export default tester(
|
92 | 87 |
|
93 | 88 | `,
|
94 | 89 | },
|
95 |
| - nuxtConfig: { |
96 |
| - modules: ['~/modules/foo', '~/modules/bar'], |
97 |
| - }, |
98 | 90 | async test() {
|
99 | 91 | await this.page.goto('http://localhost:3000')
|
100 | 92 | await this.page.waitForSelector('.bar')
|
101 | 93 | },
|
102 | 94 | },
|
103 | 95 | },
|
104 |
| - [ |
105 |
| - testerPluginTmpDir(), |
106 |
| - { |
107 |
| - transform: config => { |
108 |
| - config = { nuxtConfig: {}, nuxtVersion: 2, test: () => {}, ...config } |
109 |
| - |
110 |
| - return async function () { |
111 |
| - await outputFiles({ |
112 |
| - 'package.json': JSON.stringify({ type: 'module' }), |
113 |
| - ...config.files, |
114 |
| - }) |
115 |
| - if (config.nuxtVersion === 3) { |
116 |
| - await execaCommand('yarn add --dev nuxt') |
117 |
| - await fs.outputFile( |
118 |
| - 'nuxt.config.js', |
119 |
| - `export default ${JSON.stringify({ |
120 |
| - telemetry: false, |
121 |
| - ...config.nuxtConfig, |
122 |
| - })}` |
123 |
| - ) |
124 |
| - |
125 |
| - const nuxtPath = P.resolve( |
126 |
| - 'node_modules', |
127 |
| - '.bin', |
128 |
| - packageName`nuxt` |
129 |
| - ) |
130 |
| - await execa(nuxtPath, ['build']) |
131 |
| - |
132 |
| - const childProcess = execaCommand('node .output/server/index.mjs', { |
133 |
| - all: true, |
134 |
| - }) |
135 |
| - await pEvent(childProcess.all, 'data') |
136 |
| - try { |
137 |
| - await config.test.call(this) |
138 |
| - } finally { |
139 |
| - await kill(childProcess.pid) |
140 |
| - } |
141 |
| - } else { |
142 |
| - const nuxt = new Nuxt({ |
143 |
| - dev: false, |
144 |
| - ...config.nuxtConfig, |
145 |
| - }) |
146 |
| - if (config.error) { |
147 |
| - await expect(new Builder(nuxt).build()).rejects.toThrow( |
148 |
| - config.error |
149 |
| - ) |
150 |
| - } else { |
151 |
| - await new Builder(nuxt).build() |
152 |
| - await nuxt.listen() |
153 |
| - try { |
154 |
| - await config.test.call(this) |
155 |
| - } finally { |
156 |
| - await nuxt.close() |
157 |
| - } |
158 |
| - } |
159 |
| - } |
160 |
| - } |
161 |
| - }, |
162 |
| - }, |
163 |
| - testerPluginPuppeteer(), |
164 |
| - ] |
| 96 | + [testerPluginPuppeteer(), testerPluginNuxtConfig()] |
165 | 97 | )
|
0 commit comments