as-pect
Search…
⌃K
🚀

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.