๐Ÿ”งCLI Configuration

Configure the CLI

Currently as-pect will compile each file that matches the globs in the entries property of your configuration. The default entry glob pattern is "assembly/__tests__/**/*.spec.ts". As-pect compiles each of these files, and runs each binary separately inside it's own TestContext.

As of version 7 of as-pect, the CLI options have changed.

Options:
  -n, --no-logo                        Don't display the as-pect logo.
  -c, --config <config_location>       Specify the location of your   
                                       [as-pect.config.js] (default:  
                                       "./as-pect.config.js")
  -a, --as-config <asconfig_location>  Specify the location of the as-pect     
                                       asconfig. (default:    
                                       "./as-pect.asconfig.json")
  -v, --version                        Display the as-pect version. (default:  
                                       false)
  --init                               Initialize a testing project. (default: 
                                       false)
  --memory-size                        Initial size of imported memory in pages                                       of 64kb. (Default: 10 pages)
  --memory-max                         Set the maximum amount of memory pages  
                                       the wasm test modules can use. (Default:                                       -1, no max specified)
  -t, --test                           Match tests with the following regex.   
                                       (Default: `(:?)`)
  -g, --group                          Match test groups with the following    
                                       regex. (Default `(:?)`)
  -d, --disclude <regex>               Match test files with the following     
                                       regex, disclude them from testing.      
  -i, --include <globs>                A comma seperated list of include globs 
                                       that will include files for each test   
                                       compilation.
  -o, --output-binary                  Output the wasm binary for each test    
                                       file. (default: true)
  --no-run                             Skip running tests, and output the      
                                       binary files.
  -u, --update-snapshots               Update the existing snapshots. (default:                                       false)
  --summary                            Use the summary reporter. {yellow (This 
                                       specified.)} (default: false)
  --verbose                            Use a more verbose reporter. (default:
                                       false)
  --csv                                Use the csv reporter (output results to
                                       csv files.) (default: false)
  --json                               Use the json reporter (output results to
 json files.) (default: false)
  --reporter                           Define a custom reporter (path or
                                       module) (default: false)
  -s, --show-stats                     Show compiler stats between
                                       compilations. (default: false)
  -h, --help                           display help for command

A typical configuration is provided when you use asp --init, this must be an ESM module, and your project's `package.json` must be annotated with `"type": "module",`

export default {
  /**
   * A set of globs passed to the glob package that qualify typescript files for testing.
   */
  entries: ["assembly/__tests__/**/*.spec.ts"],
  /**
   * A set of globs passed to the glob package that quality files to be added to each test.
   */
  include: ["assembly/__tests__/**/*.include.ts"],
  /**
   * A set of regexp that will disclude source files from testing.
   */
  disclude: [/node_modules/],
  /**
   * Add your required AssemblyScript imports here.
   */
  async instantiate(memory, createImports, instantiate, binary) {
    let instance; // Imports can reference this
    const myImports = {
      env: { memory }
      // put your web assembly imports here, and return the module promise
    };
    instance = instantiate(binary, createImports(myImports));
    return instance;
  },
  /** Enable code coverage by uncommenting the following line. */
  // coverage: ["assembly/**/*.ts"],
  /**
   * Specify if the binary wasm file should be written to the file system.
   */
  outputBinary: false,
}

The instance returned by the async instantiate function represents an AssemblyScript module created by the @assemblyscript/loader package. You can read about how the loader works here.

Last updated