Back to Repositories

Testing PackagerRunner Bundle Processing in Parcel

This test suite validates the PackagerRunner functionality in Parcel, focusing on bundle packaging operations and module integration. It verifies the core bundling process by testing how PackagerRunner handles multiple module assets and configures output paths.

Test Coverage Overview

The test suite provides essential coverage for the PackagerRunner component, focusing on bundle packaging operations.

Key functionality tested includes:
  • Bundle destination path configuration
  • Multiple asset integration
  • Module resolution and packaging
  • Default Parcel configuration handling
Integration points cover module fixture loading and package configuration integration.

Implementation Analysis

The testing approach implements Jest’s asynchronous testing patterns using async/await syntax for handling bundling operations. The implementation demonstrates clean unit testing practices with proper test isolation.

Technical patterns include:
  • Fixture-based testing with module resolution
  • Configuration injection via @parcel/config-default
  • Async operation validation
  • Bundle object structure testing

Technical Details

Testing tools and setup:
  • Jest test framework
  • Flow type checking
  • Node.js path module
  • Assert library for validations
  • Parcel default configuration package
  • Custom test fixtures (module-a, module-b)

Best Practices Demonstrated

The test suite exemplifies high-quality testing practices through clear structure and proper isolation. Notable practices include:
  • Isolated test scope with proper setup
  • Async/await pattern usage
  • Fixture-based test data management
  • Clean configuration handling
  • Modular test organization

parcel-bundler/parcel

packages/core/core/test/PackagerRunner.test.js

            
// // @flow
// 'use strict';

// const PackagerRunner = require('../src/PackagerRunner');
// const assert = require('assert');
// const path = require('path');

// const config = require('@parcel/config-default');

// describe('PackagerRunner', () => {
//   it('works', async () => {
//     let bundle = {
//       destPath: path.join(__dirname, 'dist', 'bundle.js'),
//       assets: [
//         {blobs: {code: require.resolve('./fixtures/module-a')}},
//         {blobs: {code: require.resolve('./fixtures/module-b')}},
//       ],
//     };

//     let packagerRunner = new PackagerRunner({
//       parcelConfig: config,
//       options: {}
//     });

//     await packagerRunner.runPackager({ bundle });
//   });
// });