CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-snowpack

A lightning-fast frontend build tool designed to leverage JavaScript's native ESM system for unbundled development with instant browser updates.

82

1.22x
Overview
Eval results
Files

task.mdevals/scenario-1/

Test Environment Configuration Tool

Build a command-line tool that helps developers configure their Snowpack build tool to work with their test files. The tool should read a configuration and output a properly formatted Snowpack configuration file that includes test-specific settings.

Requirements

Your tool should accept a JSON input file that specifies:

  • Test file glob patterns (e.g., which files should be treated as tests)
  • Whether the project should run in test mode
  • Test environment variables that should be available

The tool should generate a valid Snowpack configuration file (snowpack.config.js) that properly integrates these test settings.

Input Format

The input JSON file will have the following structure:

{
  "testPatterns": ["**/*.test.js", "**/*.spec.js"],
  "enableTestMode": true,
  "testEnvVars": {
    "NODE_ENV": "test",
    "BABEL_ENV": "test"
  }
}

Output Format

Generate a snowpack.config.js file that includes:

  1. Proper test file pattern configuration
  2. Test mode settings
  3. Test environment variable setup
  4. Any necessary mount points for test directories

Example Behavior

Given an input file test-config.json:

{
  "testPatterns": ["**/*.test.js"],
  "enableTestMode": true,
  "testEnvVars": {
    "NODE_ENV": "test"
  }
}

Your tool should generate a snowpack.config.js that properly configures Snowpack for testing.

Test Cases

  • Given a configuration with test patterns ["**/*.test.js", "**/*.spec.js"], the tool generates a valid Snowpack config that recognizes these patterns. @test

  • Given a configuration with enableTestMode: true, the generated Snowpack config includes the test mode flag. @test

  • Given test environment variables {"NODE_ENV": "test", "BABEL_ENV": "test"}, the generated config includes these variables in the environment configuration. @test

  • Given an empty test patterns array, the tool generates a config without test-specific pattern matching. @test

Implementation

@generates

API

/**
 * Reads a test configuration file and generates a Snowpack configuration.
 *
 * @param {string} inputPath - Path to the JSON configuration file
 * @param {string} outputPath - Path where the snowpack.config.js should be written
 * @returns {Promise<void>}
 */
async function generateConfig(inputPath, outputPath);

/**
 * Validates that the input configuration is properly formatted.
 *
 * @param {Object} config - The configuration object to validate
 * @returns {boolean} True if valid, false otherwise
 */
function validateConfig(config);

module.exports = {
  generateConfig,
  validateConfig
};

Dependencies { .dependencies }

snowpack { .dependency }

Provides the build tool configuration system.

@satisfied-by

fs/promises { .dependency }

Provides file system operations for reading and writing configuration files.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-snowpack

tile.json