Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
miherlosev committed Sep 26, 2019
1 parent 247dd1c commit d1b8196
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
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

[{package.json,.eslintrc,.babelrc,.travis.yml}]
indent_size = 2
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto
*.sh text eol=lf
*.js text eol=lf
*.ts text eol=lf
*.css text eol=lf
*.html text eol=lf
*.md text eol=lf

*.png binary
*.ico binary
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/node_modules
.idea
.vscode
yarn.lock
package-lock.json
.npmrc
17 changes: 17 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "testcafe-examples",
"version": "0.0.1",
"author": {
"name": "Developer Express Inc.",
"url": "https://www.devexpress.com/"
},
"description": "This repository contains sample test files that help you learn how to use TestCafe.",
"license": "MIT",
"dependencies": {
"lodash": "^4.17.15",
"testcafe": "^1.5.0"
},
"scripts": {
"test": "testcafe chrome tests"
}
}
10 changes: 10 additions & 0 deletions tests/inject-node-module-as-custom-client-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ClientFunction } from 'testcafe';

fixture `Fixture`
.clientScripts({ module: 'lodash'});

test('Inject module as a custom client script', async t => {
const result = await t.eval(() => _.defaults({ 'a': 1 }, { 'a': 3, 'b': 2 }));

await t.expect(result).eql({ a: 1, b: 2 });
});
14 changes: 14 additions & 0 deletions tests/inspect-element-markup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Selector } from 'testcafe';

fixture `Fixture`
.page('https://devexpress.github.io/testcafe/example/');

test('How to inspect an element markup', async t => {
const selector = Selector('label[for]').addCustomDOMProperties({
outerHTML: el => el.outerHTML
});

const elementOuterHTML = await selector().outerHTML;

await t.expect(elementOuterHTML).eql('<label for="remote-testing"><input type="checkbox" name="remote" id="remote-testing">Support for testing on remote devices</label>');
});
14 changes: 14 additions & 0 deletions tests/reload-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Selector } from 'testcafe';

fixture `Fixture`
.page('https://devexpress.github.io/testcafe/example/');

test('How to reload the tested page', async t => {
await t.typeText('#developer-name', 'Peter Parker');

await t.eval(() => location.reload(true));

await t
.wait(3000)
.expect(Selector('#developer-name').value).eql('');
});

0 comments on commit d1b8196

Please sign in to comment.