Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.

Commit af42448

Browse files
Feature: package information (#1)
* Package information updated in `package.json`. * README.md added. * Pull request comment resolved.
1 parent b2ef276 commit af42448

File tree

3 files changed

+126
-4
lines changed

3 files changed

+126
-4
lines changed

README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<div align="center">
2+
<a href="https://github.com/SimplrJS">
3+
<img width="200" src="https://user-images.githubusercontent.com/7989797/27446299-b93aa76c-5785-11e7-8ef6-475f858e3291.png" />
4+
</a>
5+
</div>
6+
<h1 align="center">test-generator-cli</h1>
7+
8+
Tool to generate tests from cases.
9+
10+
## Installation
11+
12+
```sh
13+
npm install @simplrjs/test-generator-cli -g
14+
```
15+
16+
Global installation is not necessary. You can install this package with:
17+
18+
```sh
19+
npm install @simplrjs/test-generator-cli --save-dev
20+
```
21+
22+
and use it with [`npm-scripts`](https://docs.npmjs.com/misc/scripts).
23+
24+
## Command line
25+
26+
### Usage
27+
28+
```sh
29+
test-generator-cli -h
30+
```
31+
32+
### Arguments
33+
34+
| Argument | Type | Default | Description |
35+
|-------------------------------|-----------|---------------------------|-------------------------------------------------------------------------------|
36+
| -h, --help | boolean | `false` | Show help. |
37+
| -v, --version | boolean | `false` | Show current version. |
38+
| -p, --project | string | `./` | Project directory path. |
39+
40+
### Project tests structure
41+
42+
Let's say you picked `src` as your project directory.
43+
44+
```bash
45+
├── src
46+
└── tests
47+
├── cases
48+
│ ├── __tests__
49+
| └── __snapshots__
50+
│ ├── case-1
51+
│ │ ├── ...
52+
│ │ ├── test-config.json
53+
│ │ └── case.test.tpl
54+
│ └── case-2
55+
└── default.test.tpl
56+
```
57+
58+
| File / Directory | Description |
59+
|---------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
60+
| `__tests__` | Generated tests output directory. |
61+
| `__snapshots__` | Generated tests snapshots directory. |
62+
| `case-1`, `case-2` | Directories for test cases. |
63+
| `case.test.tpl` | Test template file for certain test case. It's not required. If `case.test.tpl` not found in case directory, test template will fallback to `default.test.tpl`. |
64+
| `test-config.json` | Config file for a test case. You can reach it template. Config structure is at your discretion. |
65+
| `default.test.tpl` | Default test template file. |
66+
67+
### Templates
68+
69+
Package supports two kinds of templates:
70+
71+
* `case.test.tpl` - test template file for certain test case. It's not required. If `case.test.tpl` not found in case directory, test template will fallback to `default.test.tpl`.
72+
* `default.test.tpl` - default test template file.
73+
74+
Template should be a valid TypeScript file that can have [Handlebars](http://handlebarsjs.com/) expressions.
75+
76+
#### Supported expressions
77+
78+
| Expression | Description |
79+
|-------------------------|-------------------------------------------------------|
80+
| `{{caseName}}` | Test case name. |
81+
| `{{projectDirectory}}` | Project directory path. |
82+
| `{{json testConfig}}` | Test case config file (`test-config.json`) content. |
83+
84+
#### Sample
85+
86+
```
87+
import * as path from "path";
88+
import { Bundler } from "@src/bundler";
89+
90+
test("{{caseName}}", async done => {
91+
const projectDirectory = "{{projectDirectory}}";
92+
const testConfig = {{{json testConfig}}};
93+
const entryFile = path.join(projectDirectory, testConfig.Entry);
94+
95+
try {
96+
const bundleResult = await new Bundler()
97+
.BundleAll([entryFile]);
98+
expect(bundleResult[0].bundledContent).toMatchSnapshot();
99+
done();
100+
} catch (error) {
101+
done.fail(error);
102+
}
103+
});
104+
```
105+
106+
## License
107+
108+
Released under the [MIT license](LICENSE).

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@simplrjs/test-generator-cli",
33
"version": "0.1.2",
4-
"description": "Generating tests from cases.",
4+
"description": "Tool to generate tests from cases.",
55
"main": "./dist/index.js",
66
"scripts": {
77
"build": "tsc -p .",
@@ -12,7 +12,20 @@
1212
"tslint": "tslint --project . --config ./tslint.json && echo Successfully passed tslint test.",
1313
"prepublishOnly": "npm run build"
1414
},
15-
"keywords": [],
15+
"repository": {
16+
"type": "git",
17+
"url": "git+https://github.com/SimplrJS/test-generator-cli.git"
18+
},
19+
"homepage": "https://github.com/SimplrJS/test-generator-cli",
20+
"keywords": [
21+
"SimplrJS",
22+
"tests",
23+
"generating",
24+
"tool",
25+
"ts",
26+
"TypeScript",
27+
"template"
28+
],
1629
"author": "simplrjs <simplr@quatrodev.com> (https://github.com/simplrjs)",
1730
"contributors": [
1831
"Giedrius Grabauskas <giedrius@quatrodev.com> (https://github.com/GiedriusGrabauskas)",
@@ -45,5 +58,6 @@
4558
},
4659
"publishConfig": {
4760
"access": "public"
48-
}
61+
},
62+
"license": "MIT"
4963
}

0 commit comments

Comments
 (0)