Skip to content

Commit

Permalink
Merge pull request #5 from crewdevio/development
Browse files Browse the repository at this point in the history
add: more matchers and migrate to trex imports
  • Loading branch information
RivierGrullon authored Aug 23, 2020
2 parents 7efbfd4 + e6cc9db commit b0092eb
Show file tree
Hide file tree
Showing 12 changed files with 199 additions and 86 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"deno.enable": true,
"deno.import_map": "./import_map.json",
"deno.unstable": true
}
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<a href="https://nest.land/package/merlin">
<img src="https://nest.land/badge.svg" />
</a>
<a href="https://deno.land/x/merlin">
<img src="https://img.shields.io/badge/available%20on-deno.land/x-blue.svg?style=flat&logo=deno"/>
</a>
</p>

## Merlin
Expand Down Expand Up @@ -59,6 +62,8 @@ Merlin is a [Jest](https://jestjs.io/en/)-inspired testing framework for deno.
- `isFunction(label: string, config)` evaluates if a data is a function
- `isSymbol(label: string, config)` evaluates if a data is a symbol
- `isUndefined(label: string, config)` evaluates if a data is undefined
- `isString(label: string, config)` evaluates if a data is string
- `isNumber(label: string, config)` evaluates if a data is number
- `testSame(label: string, config)` evaluates if two values are strictly the same
- `testGreaterOrEqual(label: string, config)` evaluates whether the expected data is greater than or equal to another
- `testGreater(label: string, config)` evaluates whether the expected data is greater than another
Expand All @@ -68,19 +73,20 @@ Merlin is a [Jest](https://jestjs.io/en/)-inspired testing framework for deno.
- `testFloat(label: string, config)` evaluates if two decimal numbers are equal
- `testThrows(label: string, config)` expect it throws an error
- `testThrowsSync(label: string, config)` expect it throws an async error
- `haveProperty(label: string, config)` expect an object to contain the properties in its value

### Install Merlin
#### Statics

install merlin-cli (optional)
- `Merlin.Error(msg?: string)` force to throw an error
- `Merlin.Unimplemented(msg?: string)` Use this to throw a method not implemented error
- `Merlin.Unreachable()` Use this to throw an Unreachable method error

```sh
$ deno install --allow-run -n merlin http://denopkg.com/crewdevio/merlin/cli.ts
```
### Install Merlin

or using [Trex](https://github.com/crewdevio/Trex) package manager.
install merlin-cli (optional)

```sh
$ trex getTool merlin-cli
deno install --allow-run -n merlin https://deno.land/x/merlin/cli.ts
```

### Mirrors
Expand Down Expand Up @@ -126,10 +132,16 @@ test.testEqual("two plus two is four", {
});
```

run this test in deno
run this test in deno.

```sh
merlin start
```

or

```sh
$ deno test
deno test
```

you should see this output on the console.
Expand Down Expand Up @@ -184,7 +196,7 @@ test.testEqual("Leak resources test", {
```

```sh
deno test
merlin start

test Leak resources test ... ok (5ms)

Expand Down Expand Up @@ -224,7 +236,7 @@ test.evalEquals([
output

```sh
$ deno test
merlin start

running 2 tests
test object assignment ... ok (10ms)
Expand All @@ -251,7 +263,7 @@ test.testNotEqual("two plus two not is five", {
output

```sh
$ deno test
merlin start

running 1 tests
test two plus two not is five ... FAILED (2ms)
Expand Down Expand Up @@ -286,7 +298,7 @@ test.stringContains("hello world contains orld", {
```

```sh
deno test
merlin start

test hello world contains orld ... ok (8ms)

Expand All @@ -306,7 +318,7 @@ test.fetchEqual("fetch data", {
```

```sh
deno test
merlin start

test fetch data ... ok (1440ms)

Expand All @@ -323,7 +335,7 @@ test.testRegExp("regEx match", {
```

```sh
deno test
merlin start

test regEx match ... ok (6ms)

Expand Down Expand Up @@ -415,7 +427,7 @@ It has a table with the detailed values
▒▒▒▒▒▒▒▒ Benchmarking finished

┌───────────────────────────────────────────────────────────────────────────────────────────┐
🧪 Benchmark name: Sorting arrays │
🚀 Benchmark name: Sorting arrays │
├───────────────────────┬──────────────────────────────┬────────────────────────────────────┤
│ Total runs: 1000 │ Total time: 1099.6591 ms │ Avg time: 1.0997 ms │
├───────────────────────┼────────────────────┬─────────┴───────────┬────────────────────────┤
Expand Down
4 changes: 2 additions & 2 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
*/

import { colors } from "./deps.ts";
import { colors } from "./imports/fmt.ts";

async function main() {
const [command, ...args] = Deno.args;
Expand All @@ -25,7 +25,7 @@ async function main() {
}
} else if (command === "help") {
const info = [
colors.green("merlin test runner v1.0.0 🧪\n"),
colors.green("merlin test runner v1.0.2 🧪\n"),
colors.green("usage:"),
`merlin ${colors.yellow("test")} ...allow-flags\n`,
colors.green("example:"),
Expand Down
11 changes: 0 additions & 11 deletions deps.ts

This file was deleted.

4 changes: 2 additions & 2 deletions egg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "merlin",
"description": "Testing and Benchmarking framework for deno 🧙‍♂️",
"version": "1.0.0",
"version": "1.0.2",
"entry": "./mod.ts",
"stable": true,
"unlisted": false,
Expand All @@ -10,9 +10,9 @@
"files": [
"./cli.ts",
"./src/**/*",
"./imports/**/*",
"./README.md",
"./mod.ts",
"./deps.ts",
"./LICENSE"
]
}
7 changes: 7 additions & 0 deletions imports/deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"meta": {
"fmt": "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/fmt.ts",
"testing": "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/testing.ts",
"pretty_benching": "https://deno.land/x/pretty_benching/mod.ts"
}
}
1 change: 1 addition & 0 deletions imports/fmt.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/fmt.ts";
1 change: 1 addition & 0 deletions imports/pretty_benching.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "https://deno.land/x/pretty_benching/mod.ts";
1 change: 1 addition & 0 deletions imports/testing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "http://denopkg.com/crewdevio/Trex@proxy/proxy/files/testing.ts";
23 changes: 10 additions & 13 deletions src/maven.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,29 @@
*/

import {
bench,
runBenchmarks,
BenchmarkRunOptions,
prettyBenchmarkProgress,
prettyBenchmarkResult,
colors,
} from "../deps.ts";

} from "../imports/pretty_benching.ts";
import { colors } from "../imports/fmt.ts";
import { bench } from "../imports/testing.ts";
import { Thresholds, Bench } from "./types.ts";

export class Maven {
private bench = bench;
private bench = bench.bench;

private thresholds: Thresholds = {};

private config: BenchmarkRunOptions = {};
private config: bench.BenchmarkRunOptions = {};

private indicators = [
{
benches: /./,
tableColor: colors.cyan,
modFn: () => "🧪",
modFn: () => "🚀",
},
];

private runIndicator = [{ benches: /./, modFn: () => colors.green(" ==> ") }];
private runIndicator = [{ benches: /./, modFn: () => "==> " }];

private addThreasholds(name: string) {
this.thresholds[name] = { green: 70, yellow: 90 };
Expand All @@ -51,9 +48,9 @@ export class Maven {
});
}

public async runBench(config?: BenchmarkRunOptions) {
this.config = config as BenchmarkRunOptions;
return runBenchmarks(
public async runBench(config?: bench.BenchmarkRunOptions) {
this.config = config as bench.BenchmarkRunOptions;
return bench.runBenchmarks(
{ silent: true, ...config },
prettyBenchmarkProgress({
indicators: this.runIndicator,
Expand Down
Loading

0 comments on commit b0092eb

Please sign in to comment.