A lightning-fast frontend build tool designed to leverage JavaScript's native ESM system for unbundled development with instant browser updates.
82
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.
Your tool should accept a JSON input file that specifies:
The tool should generate a valid Snowpack configuration file (snowpack.config.js) that properly integrates these test settings.
The input JSON file will have the following structure:
{
"testPatterns": ["**/*.test.js", "**/*.spec.js"],
"enableTestMode": true,
"testEnvVars": {
"NODE_ENV": "test",
"BABEL_ENV": "test"
}
}Generate a snowpack.config.js file that includes:
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.
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
@generates
/**
* 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
};Provides the build tool configuration system.
@satisfied-by
Provides file system operations for reading and writing configuration files.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-snowpackevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10