Skip to content

Commit 911d252

Browse files
committed
release v0.1.10
1 parent 1126c09 commit 911d252

File tree

20 files changed

+910
-888
lines changed

20 files changed

+910
-888
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ v0.1.6 - Fix: args should be prefixed with a space
1818
v0.1.7 - Fix: remove warning about wasi-shim not being included when it is included
1919
v0.1.8 - Feat: function mocking
2020
v0.1.9 - Fix: mocks were not being applied to declared functions, only property accesses
21+
v0.1.10 - Feat: support node, deno, and bun
2122

22-
v0.1.10 [UNRELEASED] - Feat: snapshotting
23+
[UNRELEASED] - Feat: snapshotting

README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
| _ || __| ___|_ _|| __|| __||_ _|
44
| ||__ ||___| | | | __||__ | | |
55
|__|__||_____| |_| |_____||_____| |_|
6-
v0.1.9
6+
v0.1.10
77
</pre>
88
</h5>
99

@@ -15,6 +15,15 @@ npm install as-test
1515

1616
Note: The transform _is_ OPTIONAL, though it is required to enable code coverage.
1717

18+
## Templates
19+
20+
I provide two templates for reference
21+
22+
[WASI](https://github.com/JairusSW/as-test/tree/template/wasi)
23+
[Node/Bun/Deno](https://github.com/JairusSW/as-test/tree/template/node-bun-deno)
24+
25+
View the docs: https://docs.jairus.dev/as-test
26+
1827
## Usage
1928

2029
You can setup the configuration files using
@@ -38,7 +47,7 @@ import {
3847
afterAll,
3948
beforeEach,
4049
afterEach,
41-
mock,
50+
mockFn,
4251
log,
4352
run
4453
} from "as-test";
@@ -52,7 +61,7 @@ afterAll(() => {
5261
});
5362

5463
// Mock/override the function console.log
55-
mock("console.log", (data: string): void => {
64+
mockFn<void>("console.log", (data: string): void => {
5665
console.log("[MOCKED]: " + data + "\n");
5766
});
5867

@@ -129,16 +138,6 @@ If you use this project in your codebase, consider dropping a [⭐ HERE](https:/
129138
This library is in the EARLY STAGES OF DEVELOPMENT!
130139
If you want a feature, drop an issue (and again, maybe a star). I'll likely add it in less than 7 days.
131140

132-
## Contact
133-
134-
Contact me at:
135-
136-
Email: `me@jairus.dev`
137-
138-
GitHub: `JairusSW`
139-
140-
Discord: `jairussw`
141-
142141
## Issues
143142

144143
Please submit an issue to https://github.com/JairusSW/as-test/issues if you find anything wrong with this library

as-test.config.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
},
1010
"buildOptions": {
1111
"args": [],
12-
"wasi": false,
12+
"wasi": true,
1313
"parallel": true,
1414
"verbose": true
1515
},
1616
"runOptions": {
1717
"runtime": {
18-
"name": "node",
19-
"run": "node ./test.js"
18+
"name": "wasmtime",
19+
"run": "wasmtime <file>"
2020
}
2121
}
2222
}

assembly/__tests__/example.spec.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,10 @@ import {
88
afterEach,
99
log,
1010
run,
11-
mock,
11+
mockFn,
1212
} from "..";
1313

14-
function hello(a: i32, b: i32, c: i32): void {
15-
console.log("a: " + a.toString());
16-
console.log("b: " + b.toString());
17-
console.log("c: " + c.toString());
18-
}
19-
20-
mock("hello", (a: i32, b: i32, c: i32): void => {
21-
hello(a + 10, b + 10, c + 10);
22-
});
23-
24-
mock("console.log", (data: string): void => {
14+
mockFn<void>("console.log", (data: string): void => {
2515
console.log("[MOCKED]: " + data);
2616
});
2717

@@ -47,7 +37,6 @@ describe("Math operations", () => {
4737
});
4838

4939
test("Mock", () => {
50-
hello(1, 2, 3);
5140
console.log("hello");
5241
});
5342

assembly/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ export function afterEach(callback: () => void): void {
175175
after_each_callback = callback;
176176
}
177177

178-
export function mock<returnType>(
178+
/**
179+
* Overrides all references to an existing function to instead point to this
180+
* @param {string} fn - name of function to override
181+
* @param {() => returnType} callback - the function to substitute it with
182+
*/
183+
export function mockFn<returnType>(
179184
fn: string,
180185
callback: (...args: any[]) => returnType,
181186
): void {}
@@ -235,7 +240,7 @@ export function run(options: RunOptions = new RunOptions()): void {
235240
),
236241
);
237242
console.log(
238-
rainbow.dimMk("\n------------------- v0.1.9 -------------------\n"),
243+
rainbow.dimMk("\n------------------- v0.1.10 -------------------\n"),
239244
);
240245
// @ts-ignore
241246
if (isDefined(COVERAGE_USE)) {

assembly/test.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)