@@ -7,6 +7,7 @@ import pathExists from 'path-exists';
7
7
8
8
const readfile = pify ( fs . readFile ) ;
9
9
10
+
10
11
test . before ( ( ) => {
11
12
process . chdir ( 'test' ) ;
12
13
const params = {
@@ -23,16 +24,19 @@ test.before(() => {
23
24
}
24
25
} ) ;
25
26
27
+
26
28
test ( 'Show help on no input' , async ( t ) => {
27
29
const { stdout } = await execa ( '../index.js' ) ;
28
30
t . truthy ( stdout . includes ( `$ backstop-crawl <url>` ) ) ;
29
31
} ) ;
30
32
33
+
31
34
test ( 'Failed on invalid URL' , async ( t ) => {
32
35
const { stderr } = await execa ( '../index.js' , [ 'not a url' ] , { reject : false } ) ;
33
36
t . truthy ( stderr . replace ( / \\ | \n / , '' ) === `Error: "not a url" isn't a valid URL` ) ;
34
37
} ) ;
35
38
39
+
36
40
test ( 'Default usage' , async ( t ) => {
37
41
await execa ( '../index.js' , [ 'http://0.0.0.0:8080' ] ) ;
38
42
const [ file , expected ] = await Promise . all ( [
@@ -43,6 +47,7 @@ test('Default usage', async (t) => {
43
47
return t . deepEqual ( file , expected ) ;
44
48
} ) ;
45
49
50
+
46
51
test ( 'Allow crawling subdomains' , async ( t ) => {
47
52
await execa ( '../index.js' , [ 'https://badssl.com/' , '--allow-subdomains' , '--outfile=allow-subdomains.json' ] ) ;
48
53
const [ file , expected ] = await Promise . all ( [
@@ -53,6 +58,7 @@ test('Allow crawling subdomains', async (t) => {
53
58
return t . deepEqual ( file , expected ) ;
54
59
} ) ;
55
60
61
+
56
62
test ( 'Ignore SSL errors' , async ( t ) => {
57
63
await execa ( '../index.js' , [ 'https://badssl.com/' , '--ignore-ssl-errors' , '--allow-subdomains' , '--outfile=ignore-ssl-errors.json' ] ) ;
58
64
const [ file , expected ] = await Promise . all ( [
@@ -63,6 +69,7 @@ test('Ignore SSL errors', async (t) => {
63
69
return t . deepEqual ( file , expected ) ;
64
70
} ) ;
65
71
72
+
66
73
test ( 'Ignored robots.txt' , async ( t ) => {
67
74
await execa ( '../index.js' , [ 'http://0.0.0.0:8080' , '--ignore-robots' , '--outfile=ignore-robots.json' ] ) ;
68
75
const [ file , expected ] = await Promise . all ( [
@@ -73,6 +80,7 @@ test('Ignored robots.txt', async (t) => {
73
80
return t . deepEqual ( file , expected ) ;
74
81
} ) ;
75
82
83
+
76
84
test ( 'Custom outfile' , async ( t ) => {
77
85
await execa ( '../index.js' , [ 'http://0.0.0.0:8080' , '--outfile=custom/out/file.json' ] ) ;
78
86
const [ file , expected ] = await Promise . all ( [
@@ -83,16 +91,19 @@ test('Custom outfile', async (t) => {
83
91
return t . deepEqual ( file , expected ) ;
84
92
} ) ;
85
93
94
+
86
95
test ( 'mkpath errors nicely' , async ( t ) => {
87
96
const { stderr } = await execa ( '../index.js' , [ 'http://0.0.0.0:8080' , '--outfile=fixtures/file-exists/backstop.json' ] ) ;
88
97
t . truthy ( stderr . includes ( 'fixtures/file-exists exists and is not a directory' ) ) ;
89
98
} ) ;
90
99
100
+
91
101
test ( 'jsonfile errors nicely' , async ( t ) => {
92
102
const { stderr } = await execa ( '../index.js' , [ 'http://0.0.0.0:8080' , '--outfile=fixtures/not-writeable' ] ) ;
93
103
t . truthy ( stderr . includes ( `✖ Error: EACCES: permission denied, open 'fixtures/not-writeable'` ) ) ;
94
104
} ) ;
95
105
106
+
96
107
test ( 'Debug flag produces crawl errors' , async ( t ) => {
97
108
const { stderr } = await execa ( '../index.js' , [ 'https://expired.badssl.com/' , '--debug' , '--outfile=fixtures/debug.json' ] ) ;
98
109
t . truthy ( stderr . includes ( `✖ Error: certificate has expired` ) ) ;
0 commit comments