🚀
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.
1
# initialize a node project
2
npm init
3
4
# install assemblyscript nightly
5
npm install --save-exact --save-dev [email protected]
6
7
# get the latest version of as-pect
8
npm install --save-dev @as-pect/cli
9
10
# scaffold a new project
11
npx asinit .
12
npx asp --init
Copied!
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
    🧾 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.
1
{
2
"scripts": {
3
"test": "asp --verbose",
4
"test:ci": "asp --summary"
5
}
6
}
Copied!
The command line defaults to using ./aspect.config.js, otherwise you can specify all the configuration options using the command line interface.
To change the location of the as-pect configuration, use the --config option.
1
$ npx asp --config as-pect.config.js
Copied!
Then all you need to do is write some tests!
1
const theMeaningOfLife = 42;
2
3
describe("a test group", () => {
4
test("the meaning of life", () => {
5
expect(theMeaningOfLife).toBe(42);
6
});
7
});
Copied!
Try your best to logically group tests into describe blocks so things can stay organized.
Last modified 1yr ago
Copy link