Skip to content

Commit ff67dcb

Browse files
feat: add Nightwatch for end-to-end testing (vuejs#257)
1 parent cf8ebd7 commit ff67dcb

File tree

27 files changed

+2636
-39
lines changed

27 files changed

+2636
-39
lines changed

Diff for: index.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { postOrderDirectoryTraverse, preOrderDirectoryTraverse } from './utils/d
1414
import generateReadme from './utils/generateReadme'
1515
import getCommand from './utils/getCommand'
1616
import renderEslint from './utils/renderEslint'
17+
import { FILES_TO_FILTER } from './utils/filterList'
1718

1819
function isValidPackageName(projectName) {
1920
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName)
@@ -75,6 +76,7 @@ async function init() {
7576
// --with-tests / --tests (equals to `--vitest --cypress`)
7677
// --vitest
7778
// --cypress
79+
// --nightwatch
7880
// --playwright
7981
// --eslint
8082
// --eslint-with-prettier (only support prettier through eslint for simplicity)
@@ -101,6 +103,7 @@ async function init() {
101103
argv.tests ??
102104
argv.vitest ??
103105
argv.cypress ??
106+
argv.nightwatch ??
104107
argv.playwright ??
105108
argv.eslint
106109
) === 'boolean'
@@ -119,7 +122,7 @@ async function init() {
119122
needsRouter?: boolean
120123
needsPinia?: boolean
121124
needsVitest?: boolean
122-
needsE2eTesting?: false | 'cypress' | 'playwright'
125+
needsE2eTesting?: false | 'cypress' | 'nightwatch' | 'playwright'
123126
needsEslint?: boolean
124127
needsPrettier?: boolean
125128
} = {}
@@ -134,6 +137,7 @@ async function init() {
134137
// - Install Vue Router for SPA development?
135138
// - Install Pinia for state management?
136139
// - Add Cypress for testing?
140+
// - Add Nightwatch for testing?
137141
// - Add Playwright for end-to-end testing?
138142
// - Add ESLint for code quality?
139143
// - Add Prettier for code formatting?
@@ -226,6 +230,13 @@ async function init() {
226230
: 'also supports unit testing with Cypress Component Testing',
227231
value: 'cypress'
228232
},
233+
{
234+
title: 'Nightwatch',
235+
description: answers.needsVitest
236+
? undefined
237+
: 'also supports unit testing with Nightwatch Component Testing',
238+
value: 'nightwatch'
239+
},
229240
{
230241
title: 'Playwright',
231242
value: 'playwright'
@@ -283,6 +294,8 @@ async function init() {
283294
const { needsE2eTesting } = result
284295
const needsCypress = argv.cypress || argv.tests || needsE2eTesting === 'cypress'
285296
const needsCypressCT = needsCypress && !needsVitest
297+
const needsNightwatch = argv.nightwatch || argv.tests || needsE2eTesting === 'nightwatch'
298+
const needsNightwatchCT = needsNightwatch && !needsVitest
286299
const needsPlaywright = argv.playwright || needsE2eTesting === 'playwright'
287300

288301
const root = path.join(cwd, targetDir)
@@ -329,6 +342,12 @@ async function init() {
329342
if (needsCypressCT) {
330343
render('config/cypress-ct')
331344
}
345+
if (needsNightwatch) {
346+
render('config/nightwatch')
347+
}
348+
if (needsNightwatchCT) {
349+
render('config/nightwatch-ct')
350+
}
332351
if (needsPlaywright) {
333352
render('config/playwright')
334353
}
@@ -349,6 +368,12 @@ async function init() {
349368
if (needsVitest) {
350369
render('tsconfig/vitest')
351370
}
371+
if (needsNightwatch) {
372+
render('tsconfig/nightwatch')
373+
}
374+
if (needsNightwatchCT) {
375+
render('tsconfig/nightwatch-ct')
376+
}
352377
}
353378

354379
// Render ESLint config
@@ -393,7 +418,7 @@ async function init() {
393418
root,
394419
() => {},
395420
(filepath) => {
396-
if (filepath.endsWith('.js')) {
421+
if (filepath.endsWith('.js') && !FILES_TO_FILTER.includes(path.basename(filepath))) {
397422
const tsFilePath = filepath.replace(/\.js$/, '.ts')
398423
if (fs.existsSync(tsFilePath)) {
399424
fs.unlinkSync(filepath)
@@ -437,7 +462,9 @@ async function init() {
437462
needsTypeScript,
438463
needsVitest,
439464
needsCypress,
465+
needsNightwatch,
440466
needsPlaywright,
467+
needsNightwatchCT,
441468
needsCypressCT,
442469
needsEslint
443470
})

0 commit comments

Comments
 (0)