@seleniumhq/code-export-javascript-mocha 3.17.2 → 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/LICENSE +202 -0
- package/__test__/src/command.spec.js +1 -1
- package/__test__/src/index.spec.js +2 -2
- package/package.json +4 -3
- package/src/command.js +1 -1
- package/src/hook.js +1 -1
- package/src/index.js +1 -1
- package/src/location.js +1 -1
- package/src/selection.js +1 -1
- package/dist/command.js +0 -959
- package/dist/hook.js +0 -173
- package/dist/index.js +0 -141
- package/dist/location.js +0 -68
- package/dist/selection.js +0 -57
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
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.emitTest = emitTest;
|
|
7
|
-
exports.emitSuite = emitSuite;
|
|
8
|
-
exports.default = exports.opts = exports.displayName = void 0;
|
|
9
|
-
|
|
10
|
-
var _sideUtils = require("@seleniumhq/side-utils");
|
|
11
|
-
|
|
12
|
-
var _command = _interopRequireDefault(require("./command"));
|
|
13
|
-
|
|
14
|
-
var _location = _interopRequireDefault(require("./location"));
|
|
15
|
-
|
|
16
|
-
var _hook = require("./hook");
|
|
17
|
-
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
23
|
-
|
|
24
|
-
// Define language options
|
|
25
|
-
const displayName = 'JavaScript Mocha';
|
|
26
|
-
exports.displayName = displayName;
|
|
27
|
-
let opts = {};
|
|
28
|
-
exports.opts = opts;
|
|
29
|
-
opts.emitter = _command.default;
|
|
30
|
-
opts.hooks = (0, _hook.generateHooks)();
|
|
31
|
-
opts.fileExtension = '.spec.js';
|
|
32
|
-
opts.commandPrefixPadding = ' ';
|
|
33
|
-
opts.terminatingKeyword = '})';
|
|
34
|
-
opts.commentPrefix = '//';
|
|
35
|
-
opts.generateMethodDeclaration = generateMethodDeclaration; // Create generators for dynamic string creation of primary entities (e.g., filename, methods, test, and suite)
|
|
36
|
-
|
|
37
|
-
function generateTestDeclaration(name) {
|
|
38
|
-
return `it('${name}', async function() {`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function generateMethodDeclaration(name) {
|
|
42
|
-
return {
|
|
43
|
-
body: `async function ${_sideUtils.codeExport.parsers.uncapitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}() {`,
|
|
44
|
-
terminatingKeyword: '}'
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function generateSuiteDeclaration(name) {
|
|
49
|
-
return `describe('${name}', function() {`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function generateFilename(name) {
|
|
53
|
-
return `${_sideUtils.codeExport.parsers.uncapitalize(_sideUtils.codeExport.parsers.sanitizeName(name))}${opts.fileExtension}`;
|
|
54
|
-
} // Emit an individual test, wrapped in a suite (using the test name as the suite name)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
async function emitTest({
|
|
58
|
-
baseUrl,
|
|
59
|
-
test,
|
|
60
|
-
tests,
|
|
61
|
-
project,
|
|
62
|
-
enableOriginTracing,
|
|
63
|
-
beforeEachOptions,
|
|
64
|
-
enableDescriptionAsComment
|
|
65
|
-
}) {
|
|
66
|
-
global.baseUrl = baseUrl;
|
|
67
|
-
const testDeclaration = generateTestDeclaration(test.name);
|
|
68
|
-
const result = await _sideUtils.codeExport.emit.test(test, tests, _objectSpread2({}, opts, {
|
|
69
|
-
testDeclaration,
|
|
70
|
-
enableOriginTracing,
|
|
71
|
-
enableDescriptionAsComment,
|
|
72
|
-
project
|
|
73
|
-
}));
|
|
74
|
-
const suiteName = test.name;
|
|
75
|
-
const suiteDeclaration = generateSuiteDeclaration(suiteName);
|
|
76
|
-
|
|
77
|
-
const _suite = await _sideUtils.codeExport.emit.suite(result, tests, _objectSpread2({}, opts, {
|
|
78
|
-
suiteDeclaration,
|
|
79
|
-
suiteName,
|
|
80
|
-
project,
|
|
81
|
-
beforeEachOptions
|
|
82
|
-
}));
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
filename: generateFilename(test.name),
|
|
86
|
-
body: _sideUtils.codeExport.emit.orderedSuite(_suite)
|
|
87
|
-
};
|
|
88
|
-
} // Emit a suite with all of its tests
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
async function emitSuite({
|
|
92
|
-
baseUrl,
|
|
93
|
-
suite,
|
|
94
|
-
tests,
|
|
95
|
-
project,
|
|
96
|
-
enableOriginTracing,
|
|
97
|
-
beforeEachOptions,
|
|
98
|
-
enableDescriptionAsComment
|
|
99
|
-
}) {
|
|
100
|
-
global.baseUrl = baseUrl;
|
|
101
|
-
const result = await _sideUtils.codeExport.emit.testsFromSuite(tests, suite, opts, {
|
|
102
|
-
enableOriginTracing,
|
|
103
|
-
generateTestDeclaration,
|
|
104
|
-
enableDescriptionAsComment,
|
|
105
|
-
project
|
|
106
|
-
});
|
|
107
|
-
const suiteDeclaration = generateSuiteDeclaration(suite.name);
|
|
108
|
-
|
|
109
|
-
const _suite = await _sideUtils.codeExport.emit.suite(result, tests, _objectSpread2({}, opts, {
|
|
110
|
-
suiteDeclaration,
|
|
111
|
-
suite,
|
|
112
|
-
project,
|
|
113
|
-
beforeEachOptions
|
|
114
|
-
}));
|
|
115
|
-
|
|
116
|
-
return {
|
|
117
|
-
filename: generateFilename(suite.name),
|
|
118
|
-
body: _sideUtils.codeExport.emit.orderedSuite(_suite)
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
var _default = {
|
|
123
|
-
emit: {
|
|
124
|
-
test: emitTest,
|
|
125
|
-
suite: emitSuite,
|
|
126
|
-
command: _command.default.emit,
|
|
127
|
-
locator: _location.default.emit
|
|
128
|
-
},
|
|
129
|
-
register: {
|
|
130
|
-
command: _command.default.register,
|
|
131
|
-
variable: opts.hooks.declareVariables.register,
|
|
132
|
-
dependency: opts.hooks.declareDependencies.register,
|
|
133
|
-
beforeAll: opts.hooks.beforeAll.register,
|
|
134
|
-
beforeEach: opts.hooks.beforeEach.register,
|
|
135
|
-
afterEach: opts.hooks.afterEach.register,
|
|
136
|
-
afterAll: opts.hooks.afterAll.register,
|
|
137
|
-
inEachBegin: opts.hooks.inEachBegin.register,
|
|
138
|
-
inEachEnd: opts.hooks.inEachEnd.register
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
exports.default = _default;
|
package/dist/location.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.emit = emit;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
|
|
9
|
-
var _sideUtils = require("@seleniumhq/side-utils");
|
|
10
|
-
|
|
11
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
12
|
-
// or more contributor license agreements. See the NOTICE file
|
|
13
|
-
// distributed with this work for additional information
|
|
14
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
15
|
-
// to you under the Apache License, Version 2.0 (the
|
|
16
|
-
// "License"); you may not use this file except in compliance
|
|
17
|
-
// with the License. You may obtain a copy of the License at
|
|
18
|
-
//
|
|
19
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
//
|
|
21
|
-
// Unless required by applicable law or agreed to in writing,
|
|
22
|
-
// software distributed under the License is distributed on an
|
|
23
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
24
|
-
// KIND, either express or implied. See the License for the
|
|
25
|
-
// specific language governing permissions and limitations
|
|
26
|
-
// under the License.
|
|
27
|
-
const emitters = {
|
|
28
|
-
id: emitId,
|
|
29
|
-
name: emitName,
|
|
30
|
-
link: emitLink,
|
|
31
|
-
linkText: emitLink,
|
|
32
|
-
partialLinkText: emitPartialLinkText,
|
|
33
|
-
css: emitCss,
|
|
34
|
-
xpath: emitXpath
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
function emit(location) {
|
|
38
|
-
return _sideUtils.codeExport.emit.location(location, emitters);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var _default = {
|
|
42
|
-
emit
|
|
43
|
-
};
|
|
44
|
-
exports.default = _default;
|
|
45
|
-
|
|
46
|
-
function emitId(selector) {
|
|
47
|
-
return Promise.resolve(`By.id("${selector}")`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function emitName(selector) {
|
|
51
|
-
return Promise.resolve(`By.name("${selector}")`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function emitLink(selector) {
|
|
55
|
-
return Promise.resolve(`By.linkText("${selector}")`);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function emitPartialLinkText(selector) {
|
|
59
|
-
return Promise.resolve(`By.partialLinkText("${selector}")`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function emitCss(selector) {
|
|
63
|
-
return Promise.resolve(`By.css("${selector}")`);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function emitXpath(selector) {
|
|
67
|
-
return Promise.resolve(`By.xpath("${selector}")`);
|
|
68
|
-
}
|
package/dist/selection.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.emit = emit;
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
|
|
9
|
-
var _sideUtils = require("@seleniumhq/side-utils");
|
|
10
|
-
|
|
11
|
-
// Licensed to the Software Freedom Conservancy (SFC) under one
|
|
12
|
-
// or more contributor license agreements. See the NOTICE file
|
|
13
|
-
// distributed with this work for additional information
|
|
14
|
-
// regarding copyright ownership. The SFC licenses this file
|
|
15
|
-
// to you under the Apache License, Version 2.0 (the
|
|
16
|
-
// "License"); you may not use this file except in compliance
|
|
17
|
-
// with the License. You may obtain a copy of the License at
|
|
18
|
-
//
|
|
19
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
//
|
|
21
|
-
// Unless required by applicable law or agreed to in writing,
|
|
22
|
-
// software distributed under the License is distributed on an
|
|
23
|
-
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
24
|
-
// KIND, either express or implied. See the License for the
|
|
25
|
-
// specific language governing permissions and limitations
|
|
26
|
-
// under the License.
|
|
27
|
-
const emitters = {
|
|
28
|
-
id: emitId,
|
|
29
|
-
value: emitValue,
|
|
30
|
-
label: emitLabel,
|
|
31
|
-
index: emitIndex
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function emit(location) {
|
|
35
|
-
return _sideUtils.codeExport.emit.selection(location, emitters);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var _default = {
|
|
39
|
-
emit
|
|
40
|
-
};
|
|
41
|
-
exports.default = _default;
|
|
42
|
-
|
|
43
|
-
function emitId(id) {
|
|
44
|
-
return Promise.resolve(`By.css("*[id='${id}']")`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function emitValue(value) {
|
|
48
|
-
return Promise.resolve(`By.css("*[value='${value}']")`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function emitLabel(label) {
|
|
52
|
-
return Promise.resolve(`By.xpath("//option[. = '${label}']")`);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function emitIndex(index) {
|
|
56
|
-
return Promise.resolve(`By.css("*:nth-child(${index})")`);
|
|
57
|
-
}
|