codeceptjs
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -0,1 +1,7 @@ | ||
# 0.2.2 | ||
Fixed generation of custom steps file and page objects. | ||
Please replace `require('codeceptjs/actor')` to `actor` in your `custom_steps.js`. | ||
Whenever you need to create `I` object (in page objects, custom steps, but not in tests) just call `actor()`; | ||
# 0.2.0 | ||
@@ -2,0 +8,0 @@ |
@@ -36,2 +36,3 @@ 'use strict'; | ||
global.output_dir = fsPath.join(dir, this.config.output); | ||
global.actor = require('./actor'); | ||
@@ -38,0 +39,0 @@ // initializing listeners |
@@ -9,2 +9,3 @@ 'use strict'; | ||
let ucfirst = require('../utils').ucfirst; | ||
let lcfirst = require('../utils').lcfirst; | ||
let getConfig = require('./utils').getConfig; | ||
@@ -82,3 +83,3 @@ let getTestRoot = require('./utils').getTestRoot; | ||
_init() { | ||
I = require('{{actor}}')(); | ||
I = {{actor}}(); | ||
} | ||
@@ -93,6 +94,6 @@ | ||
let config = getConfig(testsPath); | ||
let kind = opts.kind || 'page'; | ||
let kind = opts.T || 'page'; | ||
if (!config) return; | ||
output.print(`Creating a new page object`); | ||
output.print(`Creating a new ${kind} object`); | ||
output.print('--------------------------'); | ||
@@ -115,12 +116,17 @@ | ||
if (!fileExists(dir)) fs.mkdirSync(dir); | ||
let actor = config.include.I || 'codeceptjs/actor'; | ||
if (actor.charAt(0) === '.') { // relative path | ||
let relativePath = path.relative(dir, path.dirname(path.join(testsPath, config.include.I))); // get an upper level | ||
actor = relativePath + actor.substring(1); | ||
let actor = 'actor'; | ||
if (config.include.I) { | ||
let actorPath = config.include.I; | ||
if (actorPath.charAt(0) === '.') { // relative path | ||
actorPath = path.relative(dir, path.dirname(path.join(testsPath, actorPath))) + actorPath.substring(1); // get an upper level | ||
} | ||
actor = `require('${actorPath}')`; | ||
} | ||
if (!safeFileWrite(pageObjectFile, pageObjectTemplate.replace('{{actor}}', actor))) return; | ||
config.include[result.name] = result.filename; | ||
let name = lcfirst(result.name) + ucfirst(kind); | ||
config.include[name] = result.filename; | ||
updateConfig(testsPath, config); | ||
output.success(`Page object for ${result.name} was created in ${pageObjectFile}`); | ||
output.success(ucfirst(kind) + ` object for ${result.name} was created in ${pageObjectFile}`); | ||
output.print(`Use ${output.colors.bold(name)} as parameter in test scenarios to access it`); | ||
}); | ||
@@ -127,0 +133,0 @@ }; |
@@ -27,3 +27,3 @@ 'use strict'; | ||
module.exports = function() { | ||
return require('codeceptjs/actor')({ | ||
return actor({ | ||
@@ -30,0 +30,0 @@ // Define custom steps here, use 'this' to access default methods of I. |
@@ -92,3 +92,3 @@ 'use strict'; | ||
* | ||
* Receive a WebDriverIO client from a custom helper by accessing `brorwser` property: | ||
* Receive a WebDriverIO client from a custom helper by accessing `browser` property: | ||
* | ||
@@ -95,0 +95,0 @@ * ``` |
{ | ||
"name": "codeceptjs", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Modern Era Aceptance Testing Framework for NodeJS", | ||
@@ -5,0 +5,0 @@ "homepage": "http://codecept.io", |
# CodeceptJs [![NPM version][npm-image]][npm-url] [![Build Status](https://travis-ci.org/Codeception/CodeceptJS.svg)](https://travis-ci.org/Codeception/CodeceptJS) | ||
[![Join the chat at https://gitter.im/Codeception/CodeceptJS](https://badges.gitter.im/Codeception/CodeceptJS.svg)](https://gitter.im/Codeception/CodeceptJS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
Reference: [Helpers API](https://github.com/Codeception/CodeceptJS/blob/master/docs) | [Demo](https://github.com/Codeception/codeceptjs-demo) | ||
@@ -7,4 +9,4 @@ | ||
CodeceptJS is a new testing framework for end-to-end testing with WebDriver (or others). | ||
It abstracts browser interaction to simple steps which is written from a user perspective. | ||
CodeceptJS is a new testing framework for end-to-end testing with WebDriver (or others). | ||
It abstracts browser interaction to simple steps which is written from a user perspective. | ||
A simple test that verifies that "Welcome" text is present on a main page of a site will look like: | ||
@@ -19,3 +21,3 @@ | ||
} | ||
``` | ||
``` | ||
@@ -30,4 +32,4 @@ Codeception tests are: | ||
* [**WebDriverIO**](https://github.com/Codeception/CodeceptJS/blob/master/docs/API.md#webdriverio) - wrapper on top of Selenium bindings library [WebDriverIO](http://webdriver.io/) | ||
* [**FileSystem**](https://github.com/Codeception/CodeceptJS/blob/master/docs/API.md#filesystem) - simple helper for testing filesystem. | ||
* [**WebDriverIO**](https://github.com/Codeception/CodeceptJS/blob/master/docs/helpers/WebDriverIO.md) - wrapper on top of Selenium bindings library [WebDriverIO](http://webdriver.io/) | ||
* [**FileSystem**](https://github.com/Codeception/CodeceptJS/blob/master/docs/helpers/FileSystem.md) - simple helper for testing filesystem. | ||
@@ -39,4 +41,4 @@ And more to come... | ||
CodeceptJS is a successor of [Codeception](http://codeception.com), a popular full-stack testing framework for PHP. | ||
With CodeceptJS your scenario-driven functional and acceptance tests will be as simple and clean as they can be. | ||
You don't need to worry about asynchronous nature of NodeJS or about various APIs of Selenium, PhantomJS, Protractor, etc, | ||
With CodeceptJS your scenario-driven functional and acceptance tests will be as simple and clean as they can be. | ||
You don't need to worry about asynchronous nature of NodeJS or about various APIs of Selenium, PhantomJS, Protractor, etc, | ||
as CodeceptJS unifies them and makes them work as they were synchronous. | ||
@@ -51,3 +53,3 @@ | ||
* Smart locators: use names, labels, matching text, CSS or XPath to locate elements. | ||
* Interactive debugging shell: pause test at any point and try different commands in a browser. | ||
* Interactive debugging shell: pause test at any point and try different commands in a browser. | ||
* Easily create tests, pageobjects, stepobjects with CLI generators. | ||
@@ -62,3 +64,3 @@ | ||
Move to directory where you'd like to have your tests (and codeceptjs config) stored, and run | ||
Move to directory where you'd like to have your tests (and codeceptjs config) stored, and run | ||
@@ -78,3 +80,3 @@ ``` | ||
Now test is created and can be executed with | ||
Now test is created and can be executed with | ||
@@ -107,6 +109,6 @@ ``` | ||
All actions are performed by I object; assertions functions start with `see` function. | ||
All actions are performed by I object; assertions functions start with `see` function. | ||
In this examples all methods of I are taken from WebDriverIO helper, see [reference](https://github.com/Codeception/CodeceptJS/blob/master/docs/API.md#webdriverio) to learn how to use them. | ||
Let's execute this test with `run` command. Additional option `--steps` will show us the running process. We recommend use `--steps` or `--debug` during development. | ||
Let's execute this test with `run` command. Additional option `--steps` will show us the running process. We recommend use `--steps` or `--debug` during development. | ||
@@ -133,5 +135,5 @@ ``` | ||
CodeceptJS has an ultimate feature to help you develop and debug you test. | ||
CodeceptJS has an ultimate feature to help you develop and debug you test. | ||
You can **pause execution of test in any place and use interactive shell** to try different actions and locators. | ||
Just add `pause()` call at any place in a test and run it. | ||
Just add `pause()` call at any place in a test and run it. | ||
@@ -146,3 +148,3 @@ Interactive shell can be started outside test context by running: | ||
We filled form with `fillField` methods, which located form elements by their label. | ||
We filled form with `fillField` methods, which located form elements by their label. | ||
The same way you can locate element by name, CSS or XPath locators in tests: | ||
@@ -157,9 +159,9 @@ | ||
I.fillField({css: '#user_basic_email'}, 'hello@world.com'); | ||
``` | ||
``` | ||
Other methods like `checkOption`, and `click` work in a similar manner. They can take labels or CSS or XPath locators to find elements to interact. | ||
### Assertions | ||
Assertions start with `see` or `dontSee` prefix. In our case we are asserting that string 'User is valid' is somewhere in a webpage. | ||
Assertions start with `see` or `dontSee` prefix. In our case we are asserting that string 'User is valid' is somewhere in a webpage. | ||
However, we can narrow the search to particular element by providing a second parameter: | ||
@@ -177,3 +179,3 @@ | ||
In case you need to return a value from a webpage and use it directly in test, you should use methods with `grab` prefix. | ||
In case you need to return a value from a webpage and use it directly in test, you should use methods with `grab` prefix. | ||
They are expected to be used inside a generator functions, and their results will be available in test: | ||
@@ -226,3 +228,3 @@ | ||
It will create a page object file for you and add it to config. | ||
It will create a page object file for you and add it to config. | ||
Let's assume we created one named `docsPage`: | ||
@@ -236,7 +238,7 @@ | ||
module.exports = { | ||
_init() { | ||
I = require('codeceptjs/actor')(); | ||
}, | ||
fields: { | ||
@@ -243,0 +245,0 @@ email: '#user_basic_email', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99481
167941
2762
277