You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _posts/2016-01-02-development.md
+25-20Lines changed: 25 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,23 +19,24 @@ Running **create** generates:
19
19
* an example `test` directory with a few example tests
20
20
* a `package.json` configuration with some of the following settings:
21
21
22
-
23
-
{
24
-
"name": "coderoad-$TUTORIAL-NAME$",
25
-
"version": "0.1.0",
26
-
"description": "Coderoad tutorial",
27
-
"author": "Name <email> (site)",
28
-
"main": "coderoad.json",
29
-
"keywords": ["coderoad", "tutorial"],
30
-
"dependencies": {
31
-
"mocha-coderoad": "^0.3.1"
32
-
},
33
-
"coderoad": {
34
-
"testDir": "test",
35
-
"testSuffix": ".spec.js",
36
-
"testRunner": "mocha-coderoad"
37
-
}
38
-
}
22
+
```json
23
+
{
24
+
"name": "coderoad-$TUTORIAL-NAME$",
25
+
"version": "0.1.0",
26
+
"description": "Coderoad tutorial",
27
+
"author": "Name <email> (site)",
28
+
"main": "coderoad.json",
29
+
"keywords": ["coderoad", "tutorial"],
30
+
"dependencies": {
31
+
"mocha-coderoad": "^0.3.1"
32
+
},
33
+
"coderoad": {
34
+
"testDir": "test",
35
+
"testSuffix": ".spec.js",
36
+
"testRunner": "mocha-coderoad"
37
+
}
38
+
}
39
+
```
39
40
40
41
We'll learn more about these configurations when it's time to [publish](#publish).
41
42
@@ -51,9 +52,13 @@ Open a new directory for demoing your tutorial. Setup a new NPM project file.
51
52
52
53
Add your package name to the `dependencies` in `package.json`:
53
54
54
-
"dependencies": {
55
-
"coderoad-$YOUR-PACKAGE-NAME$": "^0.1.0"
56
-
}
55
+
```json
56
+
{
57
+
"dependencies": {
58
+
"coderoad-$YOUR-PACKAGE-NAME$": "^0.1.0"
59
+
}
60
+
}
61
+
```
57
62
58
63
Normally you would use `npm install` to install the package, but your package isn't ready to be published yet. Instead, you need to link your tutorial package to your demo directory.
Copy file name to clipboardExpand all lines: _posts/2016-01-03-tutorial.md
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,23 +17,25 @@ Each level of header indicates a different section, followed by a description.
17
17
18
18
As an example:
19
19
20
-
# Project Title
21
-
A description of your project
20
+
```markdown
21
+
# Project Title
22
+
A description of your project
22
23
23
-
## Chapter One Title
24
-
A description of chapter one
24
+
## Chapter One Title
25
+
A description of chapter one
25
26
26
-
### Page One Title
27
-
A description of page one
27
+
### Page One Title
28
+
A description of page one
28
29
29
-
+ A description of task one
30
+
+ A description of task one
30
31
31
-
+ A description of task two
32
+
+ A description of task two
32
33
33
-
### Page Two Title
34
-
A description of page two
34
+
### Page Two Title
35
+
A description of page two
35
36
36
-
## Chapter Two Title
37
-
etc.
37
+
## Chapter Two Title
38
+
etc.
39
+
```
38
40
39
41
[Read more](https://help.github.com/articles/working-with-advanced-formatting/) about Github Flavored Markdown, including how to write tables & syntax highlight code blocks.
Copy file name to clipboardExpand all lines: _posts/2016-01-04-coderoad-api.md
+59-36Lines changed: 59 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,21 +9,27 @@ Of course Markdown couldn't cover all uses necessary for CodeRoad. Instead, ther
9
9
10
10
For these API features to work, they must be placed at the beginning of a line.
11
11
12
-
@import('file') // ✓
13
-
@import('file') // ✗
12
+
```markdown
13
+
@import('file') // ✓
14
+
@import('file') // ✗
15
+
```
14
16
15
17
Features can be commented out, allowing you to view different files at a time. Be aware the parser matches content from the beginning of a line.
16
18
17
-
<!-- @import('file') --> // ✗
18
-
<!-- @import('file') // ✗
19
-
@import('file2') --> // ✓
19
+
```markdown
20
+
<!-- @import('file') --> // ✗
21
+
<!-- @import('file') // ✗
22
+
@import('file2') --> // ✓
23
+
```
20
24
21
25
### `@import`
22
26
23
27
*@import* loads other markdown files. Specify a relative path from the root project directory. If no file extension is provided, it will default to *.md*.
24
28
25
-
@import('./path/to/file')
26
-
@import('./path/to/file.md')
29
+
```markdown
30
+
@import('./path/to/file')
31
+
@import('./path/to/file.md')
32
+
```
27
33
28
34
See an [example](https://github.com/coderoad/coderoad-functional-school/blob/master/tutorial/tutorial.md).
29
35
@@ -32,15 +38,23 @@ See an [example](https://github.com/coderoad/coderoad-functional-school/blob/mas
32
38
33
39
Defaults for loading tests are specified in the tutorial *package.json* file.
34
40
35
-
"config": {
36
-
"testDir": "tutorial", // the directory name tests paths will load from
37
-
"testSuffix": ".spec.js" // the test file suffix that will be added
38
-
}
41
+
```json
42
+
{
43
+
"config": {
44
+
"testDir": "tutorial",
45
+
"testSuffix": ".spec.js"
46
+
}
47
+
}
48
+
```
49
+
50
+
`testDir` is appended to all @test calls, and `testSuffix` is added to the end.
39
51
40
52
*@test* loads a test file. It is important that these files are loaded in the correct order. *@test* can take a single test file, or an array of test files.
41
53
42
-
@test('path/to/file')
43
-
@test(['path/to/file', 'path/to/file2'])
54
+
```markdown
55
+
@test('path/to/file')
56
+
@test(['path/to/file', 'path/to/file2'])
57
+
```
44
58
45
59
The first example would load the file './tutorial/path/to/file.spec.js' in the project root directory.
46
60
@@ -52,16 +66,19 @@ See an [example](https://github.com/coderoad/coderoad-functional-school/blob/mas
52
66
53
67
*@hint* loads a string, or array of strings, which can be used to provide hints for the user.
54
68
55
-
@hint('A hint for the user')
56
-
@hint(['The first hint', 'The second hint'])
69
+
```markdown
70
+
@hint('A hint for the user')
71
+
@hint(['The first hint', 'The second hint'])
72
+
```
57
73
58
74
*@hint* may use code-blocks with syntax highlighting.
59
75
60
-
61
-
@hint(`var a = 42;`)
62
-
@hint(```js
63
-
var a = 42;
64
-
```)
76
+
```markdown
77
+
@hint(`var a = 42;`)
78
+
@hint(```js
79
+
var a = 42;
80
+
```)
81
+
```
65
82
66
83
### `@action`
67
84
@@ -71,32 +88,38 @@ See an [example](https://github.com/coderoad/coderoad-functional-school/blob/mas
71
88
72
89
Open a file. The path to the file will be from the users root directory.
Copy file name to clipboardExpand all lines: _posts/2016-01-05-tests.md
+25-17Lines changed: 25 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,26 +14,30 @@ Tests are loaded in their order from the tutorial markdown files, and concat tog
14
14
15
15
Tests should indicate which task they are, in order to quickly determine which task index has failed. For the *mocha-coderoad* test runner, this is as easy as adding the task number to describe block.
16
16
17
-
describe('01 first task', function () { ... });
18
-
describe('04 fourth task', function () { ... });
19
-
17
+
```js
18
+
describe('01 first task');
19
+
describe('04 fourth task');
20
+
```
20
21
21
22
### Test Statements
22
23
23
24
It makes sense to write test statements using 'should', 'must' or negative statements. Remember, the failing test message will be delivered as feedback to the user.
24
25
25
-
it('should be a function')
26
-
it('must be a function')
27
-
it('isn\'t a function')
28
-
26
+
```js
27
+
it('should be a function')
28
+
it('must be a function')
29
+
it('isn\'t a function')
30
+
```
29
31
30
32
### Loaders
31
33
32
34
Use a **loader** to run the user saved file in the context of your file. Think of a loader as a way to place the file your testing inside of your test file. Import your loader and run it on a specific user file.
33
35
34
-
var loadJS = require('path/to/loadJS').default;
35
-
loadJS('user-file.js');
36
-
// adds file contents here
36
+
```js
37
+
var loadJS =require('path/to/loadJS').default;
38
+
loadJS('user-file.js');
39
+
// adds file contents here
40
+
```
37
41
38
42
You'll have to roll your own loader to fit your project, but there are example [loaders](#loaders) included later in the docs.
39
43
@@ -47,14 +51,18 @@ Data can be loaded in the user's file by setting it as a global within the test.
47
51
48
52
Although bad practice, it can be easiest to set data to the global scope.
0 commit comments