๐Ÿš€Getting Started

The Journey of a Thousand Miles Starts with a Single Step

To get started, it's best to download the nightly version of AssemblyScript. The following bash script should help get you started.

# initialize a node project
npm init

# install assemblyscript nightly
npm install --save-dev assemblyscript

# get the latest version of as-pect
npm install --save-dev @as-pect/cli

# scaffold a new project
npx asinit .
npx asp --init

The following files will be created in your project.

  • ๐Ÿ“‚ assembly

    • ๐Ÿ“‚ __tests__

      • ๐Ÿงพ as-pect.d.ts

      • ๐Ÿงพ example.spec.ts

    • ๐Ÿงพ index.ts

    • ๐Ÿงพ tsconfig.json

  • ๐Ÿ“‚ build

    • โ• .gitignore

  • ๐Ÿ“ node_modules

  • ๐Ÿ“‚ tests

    • ๐Ÿงพ index.js

  • ๐Ÿงพ asconfig.json

  • ๐Ÿงพ as-pect.asconfig.json

  • ๐Ÿงพ as-pect.config.js

  • ๐Ÿงพ index.js

  • ๐Ÿงพ package-lock.json

  • ๐Ÿงพ package.json

Some of the testing files generated by the assemblyscript package are unnecessary like the root ๐Ÿ“‚ tests folder which can be deleted. Also, the ๐Ÿงพ example.spec.ts file can be deleted because it's merely an example set of tests to help you get started.

The ๐Ÿงพ as-pect.d.ts file is very simple. It contains a reference to the as-pect default types for intellisense reasons. To run your as-pect test suite, use the command line: npx asp, or create an npm script.

{
  "scripts": {
    "test": "asp --verbose",
    "test:ci": "asp --summary"
  }
}

The command line defaults to using ./as-pect.config.js, otherwise you can specify some the configuration options using the command line interface.

To change the location of the as-pect configuration, use the --config option.

$ npx asp --config as-pect.config.js

It's also important to inspect the `./as-pect.asconfig.json` file, as it has all the required cli options for testing.

Then all you need to do is write some tests!

const theMeaningOfLife = 42;

describe("a test group", () => {
    test("the meaning of life", () => {
        expect(theMeaningOfLife).toBe(42);
    });
});

Try your best to logically group tests into describe blocks so things can stay organized.

Last updated