Skip to content

Commit

Permalink
Merge pull request #1 from miherlosev/master
Browse files Browse the repository at this point in the history
Angular1Selector implemented
  • Loading branch information
AlexanderMoskovkin authored Aug 15, 2017
2 parents 03c3759 + e8f5e5a commit f0ac25c
Show file tree
Hide file tree
Showing 15 changed files with 603 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
15 changes: 15 additions & 0 deletions .editoreconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[{.eslintrc,package.json,.travis.yml}]
indent_size = 2
87 changes: 87 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"parser": "babel-eslint",
"extends": "eslint:recommended",
"rules": {
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-console": 0,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 0,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-undef-init": 2,
"no-unused-expressions": 2,
"no-with": 2,
"camelcase": 2,
"comma-spacing": 2,
"consistent-return": 2,
"eqeqeq": 2,
"semi": 2,
"semi-spacing": [2, {"before": false, "after": true}],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"yoda": [2, "never"],
"brace-style": [2, "stroustrup", { "allowSingleLine": false }],
"eol-last": 2,
"indent": 2,
"key-spacing": [2, { "align": "value" }],
"max-nested-callbacks": [2, 3],
"new-parens": 2,
"newline-after-var": [2, "always"],
"no-lonely-if": 2,
"no-multiple-empty-lines": [2, { "max": 2 }],
"no-nested-ternary": 2,
"no-underscore-dangle": 0,
"no-unneeded-ternary": 2,
"object-curly-spacing": [2, "always"],
"operator-assignment": [2, "always"],
"quotes": [2, "single", "avoid-escape"],
"space-before-blocks": [2, "always"],
"prefer-const": 2,
"no-path-concat": 2,
"no-undefined": 2,
"keyword-spacing": 2,
"strict": 0,
"curly": [2, "multi-or-nest"],
"dot-notation": 0,
"no-else-return": 2,
"one-var": [2, "never"],
"no-multi-spaces": [2, {
"exceptions": {
"VariableDeclarator": true,
"AssignmentExpression": true
}
}],
"radix": 2,
"no-extra-parens": 2,
"new-cap": [2, { "capIsNew": false }],
"space-before-function-paren": [2, "always"],
"no-use-before-define" : [2, "nofunc"],
"handle-callback-err": 0
},
"env": {
"node": true,
"browser": true
}
}
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

node_modules/*
.idea/*
lib/*
test/data/lib/*
13 changes: 13 additions & 0 deletions .publishrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"validations": {
"vulnerableDependencies": false,
"uncommittedChanges": true,
"untrackedFiles": true,
"sensitiveData": true,
"branch": "master",
"gitTag": true
},
"confirm": true,
"publishTag": "latest",
"prePublishScript": "npm test"
}
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,97 @@
# testcafe-angular-selectors

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.. ).

## Install

```
npm install testcafe-angular-selectors
```

## Usage

```js
import { Angular1Selector } from 'testcafe-angular-selectors';
import { Selector } from 'testcafe';

fixture `TestFixture`
.page('http://todomvc.com/examples/angularjs/');

test('add new item', async t => {
await t
.typeText(Angular1Selector.byModel('newTodo'), 'new item')
.pressKey('enter')
.expect(Selector('#todo-list').visible).ok();
});
```

See more examples [here](/test/angular1-test.js).

## Angular1 Selector extensions

### byBinding
Find elements by text binding. Does a partial match, so any elements bound to variables containing the input string will be returned.
```js
Angular1Selector.byBinding(bindingDescriptor, parentSelector)
```
Parameter | Description
--------------------------- | -----------
bindingDescriptor | The JavaScript expression to which the element's `textContent` is bound.
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.

> We don't support deprecated syntax `Angular1Selector.byBinding('{{person.name}}')`
### byExactBinding
Find elements by exact binding.
```js
Angular1Selector.byExactBinding(bindingDescriptor, parentSelector)
```
Parameter | Description
--------------------------- | -----------
bindingDescriptor | The JavaScript expression to which the element's `textContent` is bound.
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.

### byModel
Find elements by 'ng-model' expression
```js
Angular1Selector.byModel(model, parentSelector)
```
Parameter | Description
--------------------------- | -----------
model | The JavaScript expression used to bind a property on the scope to an input, select, textarea (or a custom form control).
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.

### byOptions
Find elements by 'ng-options' expression.
```js
Angular1Selector.byOptions(optionsDescriptor, parentSelector)
```
Parameter | Description
--------------------------- | -----------
optionsDescriptor | The JavaScript expression used to generate a list of <option> elements for the <select> element.
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.

### byRepeater
Find elements by repeater. Does a partial match, so any elements bound to variables containing the input string will be returned.
```js
Angular1Selector.byRepeater(repeatDescriptor, parentSelector)
```
Parameter | Description
--------------------------- | -----------
repeatDescriptor | The JavaScript expression used to instantiate a template.
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.

### byExactRepeat
Find elements by exact repeater.
```js
Angular1Selector.byExactRepeater(repeatDescriptor, parentSelector)
```
Parameter | Description
--------------------------- | -----------
repeatDescriptor | The JavaScript expression used to instantiate a template.
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.


## Angular2 Selector extensions
Angular2 component selectors is coming...
19 changes: 19 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
environment:
NODEJS_VERSION: "stable"

install:
- ps: >-
Install-Product node $env:NODEJS_VERSION
choco install GoogleChrome
choco install Firefox
- cmd: >-
npm install
build: off

test_script:
- cmd: >-
npm test
27 changes: 27 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "testcafe-angular-selectors",
"version": "0.1.0",
"scripts": {
"lint": "eslint src/*.js test/*.js",
"http-server": "http-server ./ -s",
"testcafe": "testcafe all test/*-test.js --app \"npm run http-server\"",
"test": "npm run build && npm run testcafe",
"build": "babel src --out-dir lib",
"publish-please": "publish-please",
"prepublish": "publish-please guard"
},
"devDependencies": {
"angular": "^1.6.4",
"babel-cli": "^6.22.2",
"babel-eslint": "^7.1.1",
"babel-preset-es2015": "^6.22.0",
"eslint": "^3.15.0",
"eslint-plugin-testcafe": "^0.2.1",
"http-server": "^0.9.0",
"publish-please": "^2.2.0",
"testcafe": "^0.15.0"
},
"peerDependencies": {
"testcafe": "*"
}
}
Loading

0 comments on commit f0ac25c

Please sign in to comment.