- For API test, we use mocha (https://mochajs.org/) and chai (https://www.chaijs.com/)
- For UI test (web), we use cypress (https://docs.cypress.io/guides/overview/why-cypress.html)
- For mobile apps test, (still on process)
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases. Hosted on GitHub.
Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.
Clone from https://github.com/oimtrust/isqa-cy (choose master
branch)
For windows and mac user you can download node and install. For linux user you can install with ppa the tutorial can be found here.
After node and npm installed, we recommend you to also install yarn, the tutorial can be found here.
Before start development and running the test you need to install packages that needed for flip-test project. To install them, you need to do these step:
- Go to your flip-test repo directory in your local machine with your favorite terminal.
- and run
yarn
in your terminal - wait, and done
- Use the
describe
function to create a group of test cases - Use the
it
function to create a test- The test created with
it
should follow the test cases created in testlink.
- The test created with
- Example:
describe("Android login", function () { it("Return jwt token for valid credentials", async function () { const response = await UserAPI.login(VALID_LOGIN_CREDENTIAL_ANDROID); assert.equal(response.status, 200); assert.containsAllKeys(response.data, ["token", "device_id"]); assert.isNotNull(response.data.token); }); it("Should not return jwt token for invalid credentials", async function () { const response = await UserAPI.login(INVALID_LOGIN_CREDENTIAL_ANDROID); assert.equal(response.status, 422); }); });
A selector is used for accuiring the element within the DOM.
- Use
id
to get element. - If possible ask to dev to give the
id
for every element. If it is not, we can use other way such asclass
ortag
.- Suggested
id
that should be given in the DOM element:qa-[page name]-[unique element name]
. E.g.:qa-login-submit-button
.
- Suggested
- Use dot (
.
) to separete type file, examplelogin.data.js
andlogin.test.js
. - For scenario file, it should have
[name scenario].test.js
. - For scenario file that has more than 1 word using "-", example:
payment-bca.test.js
- All variables, files, functions names SHOULD BE DECLARED IN ENGLISH! Any Bahasa declaration will be rejected.
- Make all naming concise and clear.
Prettier
has been installed in the repo.- It will automatically run when you do a git commit.
- You also can install a Prettier extension for your editor.
Eslint
has been installed in the repo.- You can install an Eslint extension for your editor.
There are tons of other sources for best practice that can be found in Google. But, some of them are:
- https://docs.cypress.io/guides/references/best-practices.html
- https://github.com/cypress-io/eslint-plugin-cypress
- https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Test-files
- https://ruleoftech.com/2019/notes-of-best-practices-for-writing-cypress-tests
-
Data If we need use data (such as input from csv, or raw data), should be created here
-
Helper If we need create function helper that can be used for steps, should be created here
-
Page Elements This folder consist of file that mention all element object from each page, example:
login.page.js
. -
Scenario All scenario files that describe what/flow of testing should be created here, example:
login.test.js
.
-
Create branch local if you want to add scenario test
-
Don't forget to merge from latest master branch
-
If you have done for your work, create merge request
-
Ping to
@reviewer_automation
in channel#mr_automation_test
-
Track it if it gets review/comments
For linux and mac user you can run the test by run these command in your terminal:
yarn run test-b2c:run
For windows user:
- Download cypress here
- Extract it
- run cypress.exe
- Browse our flip-test repo in your local machine to add in cypress dashboard
- select scenario that you want to run
To be updated later.