Skip to content

Commit

Permalink
Merge pull request #539 from GuillaumeGomez/test-generated-js
Browse files Browse the repository at this point in the history
Test generated JS
  • Loading branch information
GuillaumeGomez authored Sep 20, 2023
2 parents 0ff8477 + a3fb1ff commit 6cfd7c3
Show file tree
Hide file tree
Showing 46 changed files with 1,178 additions and 904 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"module": "readonly",
"require": "readonly"
},
"parser": "babel-eslint",
"parser": "@babel/eslint-parser",
"parserOptions": {
"ecmaVersion": 2018,
"requireConfigFile": false,
"sourceType": "module"
},
"rules": {
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 10
uses: actions/setup-node@v1
- uses: actions/checkout@v3
- name: Use Node.js 14
uses: actions/setup-node@v3
with:
node-version: '10.x'
node-version: 14
- name: Install npm dependencies
run: npm install -r
- name: Run linter
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ If you want to run test suites separately:
$ npm run api-test
$ npm run parser-test
$ npm run exported-test
$ npm run generated-test
$ npm run ui-test
```

To be noted, `ui-test` and `api-test` can be run with `--bless` to fix the differences:

```bash
$ npm run api-test -- --bless
$ npm run ui-test -- --bless
```

## Donations
Expand Down
1,861 changes: 1,008 additions & 853 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"doc-test": "node tests/test-js/doc.js",
"parser-test": "node tests/test-js/parser.js",
"exported-test": "node tests/test-js/exported_items.js",
"generated-test": "node tests/test-js/generated.js",
"lint": "eslint src tests/test-js",
"lint-fix": "eslint --fix src tests/test-js"
},
Expand All @@ -39,8 +40,9 @@
"css-unit-converter": "^1.1.2"
},
"devDependencies": {
"babel-eslint": "^10.0.2",
"eslint": "^6.1.0",
"@babel/eslint-parser": "^7.5.4",
"@babel/core": "^7.11.0",
"eslint": "^8.49.0",
"@iarna/toml": "2.2.5"
}
}
2 changes: 1 addition & 1 deletion src/commands/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ function compareArrayLike(t1, t2) {
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function parseWrite(parser) {
'("CSS selector" or "XPath", integer)';
const elems = parser.elems;

if (elems.length !== 1) {
if (elems.length === 0) {
return {'error': err + ', found nothing'};
} else if (elems.length !== 1) {
return {'error': err + `, found \`${parser.getRawArgs()}\``};
Expand Down
4 changes: 2 additions & 2 deletions src/commands/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const jsHandle = await ${varName}.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
${code.join('\n')}`;

return {
Expand Down Expand Up @@ -244,7 +244,7 @@ const jsHandle = await ${varName}.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
${code.join('\n')}`;

return {
Expand Down
4 changes: 0 additions & 4 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,10 +1083,6 @@ missing \`)\` at the end of the expression started line ${startLine}`;
this.parseJson(elems);
} else if (c === '(') {
this.parseTuple(elems);
} else if (c === '(') {
// Sub-expression.
this.increasePos();
this.parseExpression([], [')'], elems);
} else if (isLetter(c)) {
this.parseIdent(elems);
const last = elems[elems.length - 1];
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-10.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-7.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-8.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssert/bool-9.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-10.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-4.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-5.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-7.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-8.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseAssertFalse/bool-9.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ instructions = [
if (t1.length !== t2.length) {
return false;
}
for ([index, value] of t1.entries()) {
for (const [index, value] of t1.entries()) {
if (value !== t2[index]) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/basic-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"ye\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/basic-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"\\\"ye\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/basic-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"yaya\"]);
arg.setVariable(\"b\", data[\"yiyi\"]);""",
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/pseudo-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"x\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/pseudo-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"bla\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/pseudo-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"bip\"]);
arg.setVariable(\"b\", data[\"bla\"]);""",
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreCss/xpath-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const jsHandle = await parseStoreCss.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"blop\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreProperty/basic-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jsHandle = await elem.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"ye\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreProperty/basic-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jsHandle = await elem.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"\\\"ye\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreProperty/basic-3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jsHandle = await elem.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"yaya\"]);
arg.setVariable(\"b\", data[\"yiyi\"]);""",
]
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreProperty/pseudo-1.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jsHandle = await elem.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"x\"]);""",
]
wait = false
Expand Down
2 changes: 1 addition & 1 deletion tests/test-js/api-output/parseStoreProperty/pseudo-2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const jsHandle = await elem.evaluateHandle(e => {
}
return ret;
});
data = await jsHandle.jsonValue();
const data = await jsHandle.jsonValue();
arg.setVariable(\"a\", data[\"bla\"]);""",
]
wait = false
Expand Down
Loading

0 comments on commit 6cfd7c3

Please sign in to comment.