Skip to content

Commit f0ac25c

Browse files
Merge pull request #1 from miherlosev/master
Angular1Selector implemented
2 parents 03c3759 + e8f5e5a commit f0ac25c

15 files changed

Lines changed: 603 additions & 0 deletions

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["es2015"]
3+
}

.editoreconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# This file is for unifying the coding style for different editors and IDEs
2+
# editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
charset = utf-8
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = space
12+
indent_size = 4
13+
14+
[{.eslintrc,package.json,.travis.yml}]
15+
indent_size = 2

.eslintrc

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": "eslint:recommended",
4+
"rules": {
5+
"no-alert": 2,
6+
"no-array-constructor": 2,
7+
"no-caller": 2,
8+
"no-catch-shadow": 2,
9+
"no-console": 0,
10+
"no-eval": 2,
11+
"no-extend-native": 2,
12+
"no-extra-bind": 2,
13+
"no-implied-eval": 2,
14+
"no-iterator": 2,
15+
"no-label-var": 2,
16+
"no-labels": 2,
17+
"no-lone-blocks": 2,
18+
"no-loop-func": 2,
19+
"no-multi-str": 2,
20+
"no-native-reassign": 2,
21+
"no-new": 2,
22+
"no-new-func": 0,
23+
"no-new-object": 2,
24+
"no-new-wrappers": 2,
25+
"no-octal-escape": 2,
26+
"no-proto": 2,
27+
"no-return-assign": 2,
28+
"no-script-url": 2,
29+
"no-sequences": 2,
30+
"no-shadow": 2,
31+
"no-shadow-restricted-names": 2,
32+
"no-spaced-func": 2,
33+
"no-undef-init": 2,
34+
"no-unused-expressions": 2,
35+
"no-with": 2,
36+
"camelcase": 2,
37+
"comma-spacing": 2,
38+
"consistent-return": 2,
39+
"eqeqeq": 2,
40+
"semi": 2,
41+
"semi-spacing": [2, {"before": false, "after": true}],
42+
"space-infix-ops": 2,
43+
"space-unary-ops": [2, { "words": true, "nonwords": false }],
44+
"yoda": [2, "never"],
45+
"brace-style": [2, "stroustrup", { "allowSingleLine": false }],
46+
"eol-last": 2,
47+
"indent": 2,
48+
"key-spacing": [2, { "align": "value" }],
49+
"max-nested-callbacks": [2, 3],
50+
"new-parens": 2,
51+
"newline-after-var": [2, "always"],
52+
"no-lonely-if": 2,
53+
"no-multiple-empty-lines": [2, { "max": 2 }],
54+
"no-nested-ternary": 2,
55+
"no-underscore-dangle": 0,
56+
"no-unneeded-ternary": 2,
57+
"object-curly-spacing": [2, "always"],
58+
"operator-assignment": [2, "always"],
59+
"quotes": [2, "single", "avoid-escape"],
60+
"space-before-blocks": [2, "always"],
61+
"prefer-const": 2,
62+
"no-path-concat": 2,
63+
"no-undefined": 2,
64+
"keyword-spacing": 2,
65+
"strict": 0,
66+
"curly": [2, "multi-or-nest"],
67+
"dot-notation": 0,
68+
"no-else-return": 2,
69+
"one-var": [2, "never"],
70+
"no-multi-spaces": [2, {
71+
"exceptions": {
72+
"VariableDeclarator": true,
73+
"AssignmentExpression": true
74+
}
75+
}],
76+
"radix": 2,
77+
"no-extra-parens": 2,
78+
"new-cap": [2, { "capIsNew": false }],
79+
"space-before-function-paren": [2, "always"],
80+
"no-use-before-define" : [2, "nofunc"],
81+
"handle-callback-err": 0
82+
},
83+
"env": {
84+
"node": true,
85+
"browser": true
86+
}
87+
}

.gitattributes

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto
3+
4+
# Custom for Visual Studio
5+
*.cs diff=csharp
6+
7+
# Standard to msysgit
8+
*.doc diff=astextplain
9+
*.DOC diff=astextplain
10+
*.docx diff=astextplain
11+
*.DOCX diff=astextplain
12+
*.dot diff=astextplain
13+
*.DOT diff=astextplain
14+
*.pdf diff=astextplain
15+
*.PDF diff=astextplain
16+
*.rtf diff=astextplain
17+
*.RTF diff=astextplain

.gitignore

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Windows image file caches
2+
Thumbs.db
3+
ehthumbs.db
4+
5+
# Folder config file
6+
Desktop.ini
7+
8+
# Recycle Bin used on file shares
9+
$RECYCLE.BIN/
10+
11+
# Windows Installer files
12+
*.cab
13+
*.msi
14+
*.msm
15+
*.msp
16+
17+
# Windows shortcuts
18+
*.lnk
19+
20+
# =========================
21+
# Operating System Files
22+
# =========================
23+
24+
# OSX
25+
# =========================
26+
27+
.DS_Store
28+
.AppleDouble
29+
.LSOverride
30+
31+
# Thumbnails
32+
._*
33+
34+
# Files that might appear in the root of a volume
35+
.DocumentRevisions-V100
36+
.fseventsd
37+
.Spotlight-V100
38+
.TemporaryItems
39+
.Trashes
40+
.VolumeIcon.icns
41+
42+
# Directories potentially created on remote AFP share
43+
.AppleDB
44+
.AppleDesktop
45+
Network Trash Folder
46+
Temporary Items
47+
.apdisk
48+
49+
node_modules/*
50+
.idea/*
51+
lib/*
52+
test/data/lib/*

.publishrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"validations": {
3+
"vulnerableDependencies": false,
4+
"uncommittedChanges": true,
5+
"untrackedFiles": true,
6+
"sensitiveData": true,
7+
"branch": "master",
8+
"gitTag": true
9+
},
10+
"confirm": true,
11+
"publishTag": "latest",
12+
"prePublishScript": "npm test"
13+
}

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,97 @@
11
# testcafe-angular-selectors
2+
3+
This plugin provides selector extensions that make it easier to test Angular applications with [TestCafe](https://github.com/DevExpress/testcafe/). These extensions allow you to create a Selector to find elements on the page in a way that is native to Angular applications (like `binding`, `model` etc.. ).
4+
5+
## Install
6+
7+
```
8+
npm install testcafe-angular-selectors
9+
```
10+
11+
## Usage
12+
13+
```js
14+
import { Angular1Selector } from 'testcafe-angular-selectors';
15+
import { Selector } from 'testcafe';
16+
17+
fixture `TestFixture`
18+
.page('http://todomvc.com/examples/angularjs/');
19+
20+
test('add new item', async t => {
21+
await t
22+
.typeText(Angular1Selector.byModel('newTodo'), 'new item')
23+
.pressKey('enter')
24+
.expect(Selector('#todo-list').visible).ok();
25+
});
26+
```
27+
28+
See more examples [here](/test/angular1-test.js).
29+
30+
## Angular1 Selector extensions
31+
32+
### byBinding
33+
Find elements by text binding. Does a partial match, so any elements bound to variables containing the input string will be returned.
34+
```js
35+
Angular1Selector.byBinding(bindingDescriptor, parentSelector)
36+
```
37+
Parameter | Description
38+
--------------------------- | -----------
39+
bindingDescriptor | The JavaScript expression to which the element's `textContent` is bound.
40+
parentSelector *(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.
41+
42+
> We don't support deprecated syntax `Angular1Selector.byBinding('{{person.name}}')`
43+
44+
### byExactBinding
45+
Find elements by exact binding.
46+
```js
47+
Angular1Selector.byExactBinding(bindingDescriptor, parentSelector)
48+
```
49+
Parameter | Description
50+
--------------------------- | -----------
51+
bindingDescriptor | The JavaScript expression to which the element's `textContent` is bound.
52+
parentSelector *(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.
53+
54+
### byModel
55+
Find elements by 'ng-model' expression
56+
```js
57+
Angular1Selector.byModel(model, parentSelector)
58+
```
59+
Parameter | Description
60+
--------------------------- | -----------
61+
model | The JavaScript expression used to bind a property on the scope to an input, select, textarea (or a custom form control).
62+
parentSelector *(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.
63+
64+
### byOptions
65+
66+
Find elements by 'ng-options' expression.
67+
```js
68+
Angular1Selector.byOptions(optionsDescriptor, parentSelector)
69+
```
70+
Parameter | Description
71+
--------------------------- | -----------
72+
optionsDescriptor | The JavaScript expression used to generate a list of <option> elements for the <select> element.
73+
parentSelector&#160;*(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.
74+
75+
### byRepeater
76+
Find elements by repeater. Does a partial match, so any elements bound to variables containing the input string will be returned.
77+
```js
78+
Angular1Selector.byRepeater(repeatDescriptor, parentSelector)
79+
```
80+
Parameter | Description
81+
--------------------------- | -----------
82+
repeatDescriptor | The JavaScript expression used to instantiate a template.
83+
parentSelector&#160;*(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.
84+
85+
### byExactRepeat
86+
Find elements by exact repeater.
87+
```js
88+
Angular1Selector.byExactRepeater(repeatDescriptor, parentSelector)
89+
```
90+
Parameter | Description
91+
--------------------------- | -----------
92+
repeatDescriptor | The JavaScript expression used to instantiate a template.
93+
parentSelector&#160;*(optional)* | A TestCafe [selector](https://devexpress.github.io/testcafe/documentation/test-api/selecting-page-elements/selectors.html). If specified, TestCafe will search for the target element among the descendants of the element identified by this selector.
94+
95+
96+
## Angular2 Selector extensions
97+
Angular2 component selectors is coming...

appveyor.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
environment:
2+
NODEJS_VERSION: "stable"
3+
4+
install:
5+
- ps: >-
6+
Install-Product node $env:NODEJS_VERSION
7+
8+
choco install GoogleChrome
9+
10+
choco install Firefox
11+
12+
- cmd: >-
13+
npm install
14+
15+
build: off
16+
17+
test_script:
18+
- cmd: >-
19+
npm test

package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "testcafe-angular-selectors",
3+
"version": "0.1.0",
4+
"scripts": {
5+
"lint": "eslint src/*.js test/*.js",
6+
"http-server": "http-server ./ -s",
7+
"testcafe": "testcafe all test/*-test.js --app \"npm run http-server\"",
8+
"test": "npm run build && npm run testcafe",
9+
"build": "babel src --out-dir lib",
10+
"publish-please": "publish-please",
11+
"prepublish": "publish-please guard"
12+
},
13+
"devDependencies": {
14+
"angular": "^1.6.4",
15+
"babel-cli": "^6.22.2",
16+
"babel-eslint": "^7.1.1",
17+
"babel-preset-es2015": "^6.22.0",
18+
"eslint": "^3.15.0",
19+
"eslint-plugin-testcafe": "^0.2.1",
20+
"http-server": "^0.9.0",
21+
"publish-please": "^2.2.0",
22+
"testcafe": "^0.15.0"
23+
},
24+
"peerDependencies": {
25+
"testcafe": "*"
26+
}
27+
}

0 commit comments

Comments
 (0)