Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 30a9b64

Browse files
authored
fix: move typescript option (#272)
* docs: update node/chrome * fix(node): correct option for typescript * fix: move typescript option Move the typescript option under babel.typescript since it is coupled to babel
1 parent c0ea515 commit 30a9b64

10 files changed

Lines changed: 176 additions & 34 deletions

File tree

commands-common/server/src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = function createServer(options) {
1111
const http = Object.assign({ port: 9000, root: ['./'], rewrite: {} }, options.http);
1212
const instrument = Object.assign({ exclude: '**' }, options.instrument);
1313
const transform = Object.assign({ exclude: '**' }, options.transform);
14-
const typescript = utils.coerceTypescript(options.tsc || {});
1514
const babel = utils.coerceBabel({
1615
enable: true,
1716
babelPluginIstanbul: 'babel-plugin-istanbul',
@@ -33,7 +32,6 @@ module.exports = function createServer(options) {
3332
babel: {
3433
...babel,
3534
},
36-
typescript,
3735
};
3836
const app = new Koa();
3937
app.use(favicon(path.resolve(__dirname, '../aw.png')));

commands-common/transform/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function getBabelOpts(filename, argv) {
2020
}
2121

2222
function transformTypescript(filePath, sourceRoot, tsContent, argv) {
23-
const { typescript: { compiler } } = argv;
23+
const { babel: { typescript } } = argv;
2424
const { transform: { typescript: { compilerOptions, babelOptions } } } = argv;
2525
const fileName = argv.coverage ? path.basename(filePath) : filePath;
2626
compilerOptions.sourceRoot = argv.coverage ? path.resolve(path.dirname(filePath)) : sourceRoot;
@@ -32,7 +32,7 @@ function transformTypescript(filePath, sourceRoot, tsContent, argv) {
3232
compilerOptions.module = 'esnext';
3333
}
3434
const transpileOpts = { fileName, compilerOptions };
35-
const res = compiler.transpileModule(tsContent, transpileOpts);
35+
const res = typescript.transpileModule(tsContent, transpileOpts);
3636
tsContent = res.outputText; // eslint-disable-line no-param-reassign
3737
let tsBabelOpts = {
3838
sourceMaps: 'both',

commands-common/utils/src/index.js

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,11 @@ const utils = {
7171
if (typeof opt.babelPluginIstanbul === 'string') {
7272
opt.babelPluginIstanbul = importCwd(opt.babelPluginIstanbul).default; // eslint-disable-line no-param-reassign, max-len
7373
}
74+
if (typeof opt.typescript === 'string') {
75+
opt.typescript = importCwd.silent(opt.typescript); // eslint-disable-line no-param-reassign
76+
}
7477
return opt;
7578
},
76-
coerceTypescript(opt) {
77-
return {
78-
get compiler() {
79-
if (typeof opt === 'string') {
80-
return importCwd(opt);
81-
}
82-
return opt;
83-
},
84-
};
85-
},
8679
};
8780

8881
module.exports = utils;

commands/cdp/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ const cdp = {
3333
return config;
3434
})
3535
.coerce('babel', utils.coerceBabel)
36-
.coerce('tsc', utils.coerceTsc)
3736
.coerce('nyc', (opt) => {
3837
opt.sourceMap = false; // eslint-disable-line no-param-reassign
3938
opt.instrumenter = './lib/instrumenters/noop'; // eslint-disable-line no-param-reassign

commands/cdp/src/options.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ module.exports = {
5858
},
5959
type: 'object',
6060
},
61-
tsc: {
61+
'babel.typescript': {
6262
description: 'Path to typescript compiler module',
6363
default: 'typescript',
6464
type: 'string',
@@ -121,7 +121,7 @@ module.exports = {
121121
type: 'array',
122122
},
123123
'mocha.bail': {
124-
description: 'Bail on fail?',
124+
description: 'Bails on failure',
125125
default: true,
126126
type: 'boolean',
127127
},
@@ -136,7 +136,7 @@ module.exports = {
136136
type: 'number',
137137
},
138138
'mocha.useColors': {
139-
description: 'Use colors',
139+
description: 'Use colors in output',
140140
default: true,
141141
type: 'boolean',
142142
},
@@ -151,12 +151,12 @@ module.exports = {
151151
type: 'number',
152152
},
153153
'chrome.launch': {
154-
description: 'Launch Chrome?',
154+
description: 'Launch Chrome',
155155
default: true,
156156
type: 'boolean',
157157
},
158158
'chrome.devtools': {
159-
description: 'Open Chrome with dev tools?',
159+
description: 'Open Chrome with dev tools',
160160
default: false,
161161
type: 'boolean',
162162
},

commands/node/src/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,6 @@ const node = {
407407
.options(options)
408408
.config('config', configure)
409409
.coerce('babel', utils.coerceBabel)
410-
.coerce('tsc', utils.coerceTsc)
411410
.coerce('nyc', (opt) => {
412411
if (opt.babel) {
413412
// opt.require.push('babel-register');

commands/node/src/options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ module.exports = {
7474
},
7575
type: 'object',
7676
},
77-
typescript: {
77+
'babel.typescript': {
7878
description: 'Path to typescript compiler module',
7979
default: 'typescript',
8080
type: 'string',

docs/cdp.md

Lines changed: 155 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,159 @@
11
---
22
id: cdp
3-
title: Cdp
3+
title: Chrome
44
---
55

6-
WIP
6+
Run your test headless/headful in Chrome with great developer workflow. Just start the runner with
7+
8+
```
9+
npx aw chrome -c ./path/to/aw.config.js -w --coverage
10+
```
11+
12+
and start testing. It will only rerun affected tests and generate coverage accordingly.
13+
Add files, remove files as you go and change your tests to rapidly build up a test coverage.
14+
15+
## Options
16+
17+
### --config, -c [string] [default: null]
18+
19+
Path to config file.
20+
21+
### --url [string] [null]
22+
23+
Url to html file.
24+
25+
### --glob [array] [default: ['test/\*\*/\*.spec.{js,ts}']]
26+
27+
Test glob pattern.
28+
29+
### --watch [boolean] [default: false]
30+
31+
Watch for changes.
32+
33+
### --watchGlob, -wg [array] [default: ['src/\*\*/\*.{js,ts}', 'test/\*\*/\*.spec.{js,ts}']]
34+
35+
Glob pattern for watching files that will trigger a rerun.
36+
37+
### --coverage [boolean] [default: false]
38+
39+
Generate coverage.
40+
41+
### --babel.enable [boolean] [default: true]
42+
43+
Enables babel tranformation.
44+
45+
### --babel.core [string|module] [default: '']
46+
47+
Path to babel core module.
48+
49+
### --babel.babelPluginIstanbul [string|module] [default: '']
50+
51+
Path to babel plugin istanbul module.
52+
53+
### --babel.options [object] [default: {}]
54+
55+
Pass options to babel.
56+
57+
### --babel.typescript [string] [default: 'typescript']
58+
59+
Path to typescript compiler module.
60+
61+
### --transform.typescript.config [string] [default: tsconfig.json]
62+
63+
Path to typescript config file.
64+
65+
### --transform.typescript.babelOptions [object] [default: {}]
66+
67+
Pass options to babel.
68+
69+
### --transform.include [array] [default: []]
70+
71+
Include glob for transformation.
72+
73+
### --transform.exclude [array] [default: []]
74+
75+
Exclude glob for transformation.
76+
77+
### --transform.defaultExclude [array] [default: ['\*\*/coverage/\*\*','\*\*/external/\*\*','\*\*/autogenerated/\*\*','\*\*/\*.(html|css|json|txt|ttf|woff|svg)','\*\*/\*require\*.js','\*\*/\*sinon\*.js','\*\*/\*chai\*.js']]
78+
79+
Default exclude glob for transformation.
80+
81+
### --instrument.include [array] [default: []]
82+
83+
Include glob for instrumentation.
84+
85+
### --instrument.exclude [array] [default: []]
86+
87+
Exclude glob for instrumentation.
88+
89+
### --instrument.defaultExclude [array] [default: ['\*\*/coverage/\*\*','\*\*/external/\*\*','\*\*/autogenerated/\*\*','\*\*/\*.(html|css|json|txt|ttf|woff|svg)','\*\*/\*require\*.js','\*\*/\*sinon\*.js','\*\*/\*chai\*.js','\*\*/\*.spec.{js,ts}']]
90+
91+
### --mocha.reporter [string] [default: undefined]
92+
93+
Which reporter to use.
94+
95+
Check Mochas [**list**](https://mochajs.org/#reporters) for valid options.
96+
97+
98+
### --mocha.bail [boolean] [default: true]
99+
100+
Bails on failure
101+
102+
### --mocha.timeout [number] [default: undefined]
103+
104+
Timeout in ms.
105+
106+
### --mocha.ui [string] [default: 'bdd']
107+
108+
The test interface to use.
109+
110+
### --mocha.useColors [boolean] [default: true]
111+
112+
Use colors in output.
113+
114+
### --client.port [number] [default: 9222]
115+
116+
Chrome port.
117+
118+
### --client.launch [boolean] [default: true]
119+
120+
Launch Chrome.
121+
122+
### --client.devtools [boolean] [default: false]
123+
124+
Open Chrome with dev tools.
125+
126+
### --chrome.port [number] [default: 9222]
127+
128+
Chrome port.
129+
130+
### --chrome.flags [array] [default: ['--headless', '--disable-gpu', '--allow-file-access-from-files']]
131+
132+
Chrome flags.
133+
134+
### --nyc.include [array] [default: []]
135+
136+
### --http.port [number] [default: 9676]
137+
138+
Http port.
139+
140+
### --http.root [array] [default: ['./']]
141+
142+
Root folders to serve.
143+
144+
### --http.rewrite [object] [default: {}
145+
146+
Rewrite url(s).
147+
148+
### --nyc.tempDirectory [string] [default: './coverage/.nyc_output']
149+
150+
Directory to output raw coverage information to.
151+
152+
### --nyc.reporter [array] [default: ['lcov', 'text-summary']]
153+
154+
Coverage reporter(s) to use.
155+
156+
157+
### --nyc.reportDir [string] [default: 'coverage']
158+
159+
Directory to output coverage reports in.

docs/node.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Add files, remove files as you go and change your tests to rapidly build up a te
1616

1717
We are using the awesome 💖 [**jest-snapshot**](https://github.com/facebook/jest/tree/master/packages/jest-snapshot) package.
1818

19-
<summary><details>
19+
<details><summary>Example</summary>
2020
<p>
2121

2222
```javascript
@@ -42,16 +42,16 @@ describe('button', () => {
4242
```
4343

4444
</p>
45-
</details></summary>
45+
</details>
4646

4747

4848
## Options
4949

50-
### \-\-presetEnv [boolean] [default: true]
50+
### --presetEnv [boolean] [default: true]
5151

5252
Preset the test environment with Sinon, Chai, Sinon-Chai, Chai as promised and Chai subset.
5353

54-
<summary><details>
54+
<details><summary>Details</summary>
5555
<p>
5656

5757
```javascript
@@ -83,7 +83,7 @@ describe('hello', () => {
8383
```
8484

8585
</p>
86-
</details></summary>
86+
</details>
8787

8888
### --config, -c [string] [default: null]
8989

@@ -144,13 +144,13 @@ Path to babel plugin istanbul module
144144

145145
Pass options to babel
146146

147-
### --typescript [string] [default: 'typescript']
147+
### --babel.typescript [string] [default: 'typescript']
148148

149149
Path to typescript compiler module
150150

151151
### --mocks [array] [default: [['\*.{scss,less,css}']],]
152152

153-
<summary><details>
153+
<details><summary>Details</summary>
154154
<p>
155155

156156
```javascript
@@ -164,11 +164,11 @@ mocks: [
164164
```
165165

166166
</p>
167-
</details></summary>
167+
</details>
168168

169169
### --mocha.reporter [string] [default: undefined]
170170

171-
Which reporter to use.
171+
Which reporter to use.
172172

173173
Check Mochas [**list**](https://mochajs.org/#reporters) for valid options.
174174

website/i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"next": "Next",
55
"previous": "Previous",
66
"tagline": "Testing, made simple",
7-
"cdp": "Cdp",
7+
"cdp": "Chrome",
88
"installation": "Installation",
99
"node": "Node",
1010
"protractor": "Protractor",

0 commit comments

Comments
 (0)