Repository navigation
Expand file tree
/
Copy pathTestingTask.js
More file actions
87 lines (67 loc) · 1.67 KB
/
Copy pathTestingTask.js
File metadata and controls
87 lines (67 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class TestingTask extends Elixir.Task {
/**
* Create a new TestingTask instance.
*
* @param {string} name
* @param {string|null} src
* @param {string|null} command
*/
constructor(name, src, command) {
super(name);
this.src = src;
this.command = command;
}
/**
* Build up the Gulp task.
*/
gulpTask() {
return (
gulp
.src('')
.pipe(this.runTests())
.on('error', this.onError())
.pipe(this.onSuccess())
);
}
/**
* Register file watchers.
*/
registerWatchers() {
this.watch(this.src || this.pluginConfig('path') + this.pluginConfig('search'))
.watch(Elixir.config.appPath + '/**/*.php', 'tdd')
.watch(Elixir.config.viewPath + '/**/*.php', 'tdd');
}
/**
* Trigger the test suite.
*/
runTests() {
let command = this.command || this.pluginConfig('command');
this.recordStep('Executing ' + this.ucName());
return Elixir.Plugins.shell(command);
}
/**
* Handle any errors.
*/
onError() {
let task = this.name;
return function (e) {
Elixir.Notification.forFailedTests(e, task);
this.emit('end');
};
}
/**
* Handle a "green" test suite.
*/
onSuccess() {
return Elixir.Notification.forPassedTests(this.name);
}
/**
* Retrieve the test suite configuration.
*
* @param {string} prop
*/
pluginConfig(prop) {
return Elixir.config.testing[this.name][prop];
}
}
export default TestingTask;