Setup Gulp uses Vitest as its test runner, paired with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/jpachecox/setup-gulp/llms.txt
Use this file to discover all available pages before exploring further.
jsdom environment so that tests can interact with browser-like DOM APIs without launching a real browser. Coverage is collected through the V8 provider and reported as text, JSON, and HTML. An optional browser-based UI is available for interactive test exploration during development.
Test runner: Vitest
Vitest ^1.5.0 is configured withglobals: true and environment: 'jsdom', meaning the full set of Vitest globals (test, expect, describe, beforeEach, etc.) is available in every test file without explicit imports, and DOM APIs such as document and window are provided by jsdom.
Test files live in the __tests__/ directory at the project root and follow the *.test.ts naming convention. Three npm scripts cover the most common workflows:
Vitest configuration
The full configuration is defined invitest.config.ts at the project root:
environment: 'jsdom'
environment: 'jsdom'
Provides a simulated browser environment for every test file. DOM APIs such as
document.querySelector, window, and localStorage are available without any additional setup. This is particularly useful for tests that verify DOM structure or browser-facing utilities.globals: true
globals: true
Makes
test(), expect(), describe(), beforeEach(), and all other Vitest globals available without an explicit import statement at the top of each test file. This keeps test files concise and matches the Jest authoring style.gulpfile.js exclusion
gulpfile.js exclusion
gulpfile.js uses ESM import syntax and Gulp-specific APIs that are incompatible with the Vitest/Node.js test runner. Excluding it from both test.exclude and coverage.exclude prevents false failures and keeps coverage metrics focused on the actual application source.coverage.provider: 'v8'
coverage.provider: 'v8'
Uses Node.js’s built-in V8 coverage engine via
@vitest/coverage-v8. V8 coverage is faster than instrumentation-based alternatives and requires no Babel transforms, making it a natural fit for a TypeScript project that already uses Babel for compilation.Included test examples
The project ships with two test files that serve as practical starting points.sum.test.ts — unit testing a utility function
__tests__/sum.test.ts imports and exercises the sum() helper from src/js/sum.ts, demonstrating typed assertions in a minimal unit test:
src/js/sum.ts
__tests__/sum.test.ts
toBe. The explicit type annotations on result and expected mean TypeScript will catch any future signature changes at compile time before the test even runs.
sass.test.ts — file system integrity test
__tests__/sass.test.ts verifies that every required SCSS partial exists on disk before the build starts, catching missing files early rather than at Gulp task execution time:
__tests__/sass.test.ts
Writing new tests
Follow these conventions when adding test files to the project:Place test files in __tests__/
All test files should live in the
__tests__/ directory at the project root. Vitest will discover them automatically based on its default include glob.Use the *.test.ts naming convention
Name every test file with a
.test.ts extension. This makes the purpose of the file immediately obvious and ensures Vitest picks it up without any additional configuration.Import from src/ using relative paths
Reference source files using relative paths from
__tests__/ to src/. For example, a utility at src/js/utils.ts is imported as import { myUtil } from '../src/js/utils'.Coverage reports are written to the
coverage/ directory in three formats after running yarn coverage: a text summary printed to the terminal, a JSON file for programmatic consumption or CI integration, and an HTML report you can open in a browser for a line-by-line breakdown. The coverage/ directory is excluded from coverage measurement itself to avoid skewed metrics.