@seleniumhq/code-export-javascript-mocha 3.16.1 → 3.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hook.js DELETED
@@ -1,173 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateHooks = generateHooks;
7
-
8
- var _sideUtils = require("@seleniumhq/side-utils");
9
-
10
- // Licensed to the Software Freedom Conservancy (SFC) under one
11
- // or more contributor license agreements. See the NOTICE file
12
- // distributed with this work for additional information
13
- // regarding copyright ownership. The SFC licenses this file
14
- // to you under the Apache License, Version 2.0 (the
15
- // "License"); you may not use this file except in compliance
16
- // with the License. You may obtain a copy of the License at
17
- //
18
- // http://www.apache.org/licenses/LICENSE-2.0
19
- //
20
- // Unless required by applicable law or agreed to in writing,
21
- // software distributed under the License is distributed on an
22
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- // KIND, either express or implied. See the License for the specific language governing permissions and limitations
24
- // under the License.
25
- const emitters = {
26
- afterAll,
27
- afterEach,
28
- beforeAll,
29
- beforeEach,
30
- declareDependencies,
31
- declareMethods: empty,
32
- declareVariables,
33
- inEachBegin: empty,
34
- inEachEnd: empty
35
- };
36
-
37
- function generate(hookName) {
38
- return new _sideUtils.codeExport.hook(emitters[hookName]());
39
- }
40
-
41
- function generateHooks() {
42
- let result = {};
43
- Object.keys(emitters).forEach(hookName => {
44
- result[hookName] = generate(hookName);
45
- });
46
- return result;
47
- }
48
-
49
- function afterAll() {
50
- const params = {
51
- startingSyntax: {
52
- commands: [{
53
- level: 0,
54
- statement: 'afterAll(async function() {'
55
- }]
56
- },
57
- endingSyntax: {
58
- commands: [{
59
- level: 0,
60
- statement: '})'
61
- }]
62
- },
63
- registrationLevel: 1
64
- };
65
- return params;
66
- }
67
-
68
- function afterEach() {
69
- const params = {
70
- startingSyntax: {
71
- commands: [{
72
- level: 0,
73
- statement: 'afterEach(async function() {'
74
- }, {
75
- level: 1,
76
- statement: 'await driver.quit();'
77
- }]
78
- },
79
- endingSyntax: {
80
- commands: [{
81
- level: 0,
82
- statement: '})'
83
- }]
84
- }
85
- };
86
- return params;
87
- }
88
-
89
- function beforeAll() {
90
- const params = {
91
- startingSyntax: {
92
- commands: [{
93
- level: 0,
94
- statement: 'beforeAll(async function() {'
95
- }]
96
- },
97
- endingSyntax: {
98
- commands: [{
99
- level: 0,
100
- statement: '})'
101
- }]
102
- },
103
- registrationLevel: 1
104
- };
105
- return params;
106
- }
107
-
108
- function beforeEach() {
109
- const params = {
110
- startingSyntax: ({
111
- browserName,
112
- gridUrl
113
- } = {}) => ({
114
- commands: [{
115
- level: 0,
116
- statement: 'beforeEach(async function() {'
117
- }, {
118
- level: 1,
119
- statement: `driver = await new Builder().forBrowser('${browserName ? browserName.toLowerCase() : 'chrome'}')${gridUrl ? `.usingServer('${gridUrl}')` : ''}.build()`
120
- }, {
121
- level: 1,
122
- statement: 'vars = {}'
123
- }]
124
- }),
125
- endingSyntax: {
126
- commands: [{
127
- level: 0,
128
- statement: '})'
129
- }]
130
- }
131
- };
132
- return params;
133
- }
134
-
135
- function declareDependencies() {
136
- const params = {
137
- startingSyntax: {
138
- commands: [{
139
- level: 0,
140
- statement: `const { Builder, By, Key, until } = require('selenium-webdriver')`
141
- }, {
142
- level: 0,
143
- statement: `const assert = require('assert')`
144
- }, {
145
- level: 0,
146
- statement: ''
147
- }]
148
- }
149
- };
150
- return params;
151
- }
152
-
153
- function declareVariables() {
154
- const params = {
155
- startingSyntax: {
156
- commands: [{
157
- level: 0,
158
- statement: `this.timeout(30000)`
159
- }, {
160
- level: 0,
161
- statement: `let driver`
162
- }, {
163
- level: 0,
164
- statement: 'let vars'
165
- }]
166
- }
167
- };
168
- return params;
169
- }
170
-
171
- function empty() {
172
- return {};
173
- }
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let afterAll = `
24
- @AfterAll
25
- public void finalTearDown() {
26
- `;
27
-
28
- let hooks = [];
29
-
30
- function register(statement) {
31
- hooks.push(statement);
32
- }
33
-
34
- function clear() {
35
- hooks = [];
36
- }
37
-
38
- function emit({ isOptional } = { isOptional: false }) {
39
- if (isOptional && !hooks.length) return '';
40
- return afterAll + hooks.join('\r\n') + ` }
41
- `;
42
- }
43
-
44
- exports.default = {
45
- register,
46
- clear,
47
- emit
48
- };
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let afterEach = `
24
- @After
25
- public void tearDown() {
26
- driver.quit();
27
- `;
28
-
29
- let hooks = [];
30
-
31
- function register(statement) {
32
- hooks.push(statement);
33
- }
34
-
35
- function clear() {
36
- hooks = [];
37
- }
38
-
39
- function emit({ isOptional } = { isOptional: false }) {
40
- if (isOptional && !hooks.length) return '';
41
- return afterEach + hooks.join('\r\n') + ` }
42
- `;
43
- }
44
-
45
- exports.default = {
46
- register,
47
- clear,
48
- emit
49
- };
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let beforeAll = `
24
- @BeforeAll
25
- public void initialSetUp() {
26
- `;
27
-
28
- let hooks = [];
29
-
30
- function register(statement) {
31
- hooks.push(statement);
32
- }
33
-
34
- function clear() {
35
- hooks = [];
36
- }
37
-
38
- function emit({ isOptional } = { isOptional: false }) {
39
- if (isOptional && !hooks.length) return '';
40
- return beforeAll + hooks.join('\r\n') + ` }
41
- `;
42
- }
43
-
44
- exports.default = {
45
- register,
46
- clear,
47
- emit
48
- };
@@ -1,50 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let beforeEach = `
24
- @Before
25
- public void setUp() {
26
- driver = new FirefoxDriver();
27
- js = (JavascriptExecutor) driver;
28
- `;
29
-
30
- let hooks = [];
31
-
32
- function register(statement) {
33
- hooks.push(statement);
34
- }
35
-
36
- function clear() {
37
- hooks = [];
38
- }
39
-
40
- function emit({ isOptional } = { isOptional: false }) {
41
- if (isOptional && !hooks.length) return '';
42
- return beforeEach + hooks.join('\r\n') + ` }
43
- `;
44
- }
45
-
46
- exports.default = {
47
- register,
48
- clear,
49
- emit
50
- };
@@ -1,66 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let dependencies = `
24
- import org.junit.Test;
25
- import org.junit.Before;
26
- import org.junit.After;
27
- import static org.junit.Assert.*;
28
- import static org.hamcrest.CoreMatchers.is;
29
- import static org.hamcrest.core.IsNot.not;
30
- import org.openqa.selenium.By;
31
- import org.openqa.selenium.WebDriver;
32
- import org.openqa.selenium.firefox.FirefoxDriver;
33
- import org.openqa.selenium.Dimension;
34
- import org.openqa.selenium.WebElement;
35
- import org.openqa.selenium.interactions.Actions;
36
- import org.openqa.selenium.support.ui.ExpectedConditions;
37
- import org.openqa.selenium.support.ui.WebDriverWait;
38
- import org.openqa.selenium.JavascriptExecutor;
39
- import org.openqa.selenium.Alert;
40
- import org.openqa.selenium.Keys;
41
- import java.util.HashMap;
42
- import java.util.List;
43
- import java.util.ArrayList;
44
-
45
- `;
46
-
47
- let hooks = [];
48
-
49
- function register(statement) {
50
- hooks.push(statement);
51
- }
52
-
53
- function clear() {
54
- hooks = [];
55
- }
56
-
57
- function emit({ isOptional } = { isOptional: false }) {
58
- if (isOptional && !hooks.length) return '';
59
- return dependencies + hooks.join('\r\n');
60
- }
61
-
62
- exports.default = {
63
- register,
64
- clear,
65
- emit
66
- };
@@ -1,53 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let hooks = [];
24
-
25
- function register(name, commands) {
26
- let result = '';
27
- result += `
28
- public void ${name}() {
29
- `;
30
- if (commands) {
31
- commands.forEach(command => {
32
- result += `\t${command}
33
- `;
34
- });
35
- }
36
- result += `}`;
37
- if (!hooks.includes(result)) hooks.push(result);
38
- }
39
-
40
- function clear() {
41
- hooks = [];
42
- }
43
-
44
- function emit({ isOptional } = { isOptional: false }) {
45
- if (isOptional && !hooks.length) return '';
46
- return hooks.length ? hooks.join('\n\r') : '';
47
- }
48
-
49
- exports.default = {
50
- register,
51
- clear,
52
- emit
53
- };
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let variables = `
24
- private WebDriver driver;
25
- private HashMap<String, Object> vars = new HashMap<String, Object>();
26
- JavascriptExecutor js;
27
- `;
28
-
29
- let hooks = [];
30
-
31
- function register(statement) {
32
- hooks.push(statement);
33
- }
34
-
35
- function clear() {
36
- hooks = [];
37
- }
38
-
39
- function emit({ isOptional } = { isOptional: false }) {
40
- if (isOptional && !hooks.length) return '';
41
- return variables + hooks.join('\r\n');
42
- }
43
-
44
- exports.default = {
45
- register,
46
- clear,
47
- emit
48
- };
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let hooks = [];
24
-
25
- function register(statement) {
26
- hooks.push(statement);
27
- }
28
-
29
- function clear() {
30
- hooks = [];
31
- }
32
-
33
- function emit({ isOptional } = { isOptional: false }) {
34
- if (isOptional && !hooks.length) return '';
35
- return hooks.join('\r\n');
36
- }
37
-
38
- exports.default = {
39
- register,
40
- clear,
41
- emit
42
- };
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let hooks = [];
24
-
25
- function register(statement) {
26
- hooks.push(statement);
27
- }
28
-
29
- function clear() {
30
- hooks = [];
31
- }
32
-
33
- function emit({ isOptional } = { isOptional: false }) {
34
- if (isOptional && !hooks.length) return '';
35
- return hooks.join('\r\n');
36
- }
37
-
38
- exports.default = {
39
- register,
40
- clear,
41
- emit
42
- };
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- // Licensed to the Software Freedom Conservancy (SFC) under one
7
- // or more contributor license agreements. See the NOTICE file
8
- // distributed with this work for additional information
9
- // regarding copyright ownership. The SFC licenses this file
10
- // to you under the Apache License, Version 2.0 (the
11
- // "License"); you may not use this file except in compliance
12
- // with the License. You may obtain a copy of the License at
13
- //
14
- // http://www.apache.org/licenses/LICENSE-2.0
15
- //
16
- // Unless required by applicable law or agreed to in writing,
17
- // software distributed under the License is distributed on an
18
- // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
- // KIND, either express or implied. See the License for the
20
- // specific language governing permissions and limitations
21
- // under the License.
22
-
23
- let hooks = [];
24
-
25
- function register(statement) {
26
- hooks.push(statement);
27
- }
28
-
29
- function clear() {
30
- hooks = [];
31
- }
32
-
33
- function emit({ isOptional } = { isOptional: false }) {
34
- if (isOptional && !hooks.length) return '';
35
- return hooks.join('\r\n');
36
- }
37
-
38
- exports.default = {
39
- register,
40
- clear,
41
- emit
42
- };