Skip to content

Commit

Permalink
Merge branch 'testomatio:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ollllla authored Apr 29, 2024
2 parents a811b05 + 7d34bd0 commit 9b272a8
Show file tree
Hide file tree
Showing 137 changed files with 3,666 additions and 148 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/codeceptjs-reporting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# - cron: "0 5 */2 * *"
name: CodeceptJS example reporting results

on:
schedule:
- cron: "0 5 */6 * *"

jobs:
reporting:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./codeceptJS

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup dependancies
run: npm i
- name: Playwright browser updates
run: npx playwright install
- name: Run tests
run: bash run-tests-and-check-results.sh
env:
TESTOMATIO: "${{ secrets.TESTOMATIO }}"
TESTOMATIO_URL: "${{ secrets.TESTOMATIO_URL }}"
CODECEPT_GROUP_TESTS: "${{ secrets.CODECEPT_GROUP_TESTS }}"
34 changes: 34 additions & 0 deletions .github/workflows/cypress-reporting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# - cron: "10 5 */2 * *"
name: Cypress example reporting results

on:
schedule:
- cron: "10 5 */6 * *"

jobs:
reporting:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./cypress

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup dependancies
run: npm i
- name: Run tests
run: bash run-tests-and-check-results.sh
env:
TESTOMATIO: "${{ secrets.TESTOMATIO_CYPRESS }}"
TESTOMATIO_URL: "${{ secrets.TESTOMATIO_URL }}"
35 changes: 35 additions & 0 deletions .github/workflows/newman-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: newman tests
on:
pull_request:
branches: [master]

concurrency:
group: newman-tests-${{github.event.pull_request.number}}
cancel-in-progress: true

jobs:
newman-global:
runs-on: ubuntu-latest
defaults:
run:
working-directory: newman
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 18.x
- run: npm i newman-reporter-testomatio newman -g
- run: TESTOMATIO=m6ef70356h7c newman run collection.json -e env.json -r testomatio

newman-local:
runs-on: ubuntu-latest
defaults:
run:
working-directory: newman
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: 18.x
- run: npm i
- run: TESTOMATIO=m6ef70356h7c npm run test
36 changes: 36 additions & 0 deletions .github/workflows/playwright-reporting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# - cron: "20 5 */2 * *"
name: Playwright example reporting results

on:
schedule:
- cron: "20 5 */6 * *"

jobs:
reporting:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./playwright

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Setup dependancies
run: npm i
- name: Playwright browser updates
run: npx playwright install
- name: Run tests
run: bash run-tests-and-check-results.sh
env:
TESTOMATIO: "${{ secrets.TESTOMATIO_PLAYWRIGHT }}"
TESTOMATIO_URL: "${{ secrets.TESTOMATIO_URL }}"
2 changes: 2 additions & 0 deletions codeceptJS-typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
output/
6 changes: 6 additions & 0 deletions codeceptJS-typescript/__tests__/open-google_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature('Test feature name');

Scenario('test something', ({ I }) => {
I.amOnPage('https://www.google.com/');
I.see('Google');
});
30 changes: 30 additions & 0 deletions codeceptJS-typescript/codecept.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { setHeadlessWhen, setCommonPlugins } from '@codeceptjs/configure';
// turn on headless mode when running with HEADLESS=true environment variable
// export HEADLESS=true && npx codeceptjs run
setHeadlessWhen(process.env.HEADLESS);

// enable all common plugins https://github.com/codeceptjs/configure#setcommonplugins
setCommonPlugins();

export const config: CodeceptJS.MainConfig = {
tests: './__tests__/**/*_test.ts',
output: './output',
helpers: {
Playwright: {
browser: 'chromium',
url: 'http://localhost',
show: false
}
},
include: {
I: './steps_file'
},
name: 'codeceptJS-typescript',

plugins: {
testomatio: {
enabled: true,
require: '@testomatio/reporter/lib/adapter/codecept',
}
}
}
19 changes: 19 additions & 0 deletions codeceptJS-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "codeceptjs-typescript",
"version": "1.0.0",
"description": "Example project for CodeceptJS + TypeScript",
"scripts": {
"test": "npx codeceptjs run --steps"
},
"author": "Oleksandr Pelykh / Testomatio",
"license": "ISC",
"dependencies": {
"codeceptjs": "^3.5.11",
"playwright": "^1.40.1"
},
"devDependencies": {
"@types/node": "^20.10.7",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
11 changes: 11 additions & 0 deletions codeceptJS-typescript/steps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// <reference types='codeceptjs' />
type steps_file = typeof import('./steps_file');

declare namespace CodeceptJS {
interface SupportObject { I: I, current: any }
interface Methods extends Playwright {}
interface I extends ReturnType<steps_file> {}
namespace Translation {
interface Actions {}
}
}
10 changes: 10 additions & 0 deletions codeceptJS-typescript/steps_file.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// in this file you can append custom step methods to 'I' object

export = function() {
return actor({

// Define custom steps here, use 'this' to access default methods of I.
// It is recommended to place a general 'login' function here.

});
}
16 changes: 16 additions & 0 deletions codeceptJS-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"ts-node": {
"files": true
},
"compilerOptions": {
"target": "es2018",
"lib": ["es2018", "DOM"],
"esModuleInterop": true,
"module": "commonjs",
"strictNullChecks": false,
"types": ["codeceptjs", "node"],
"declaration": true,
"skipLibCheck": true
},
"exclude": ["node_modules"]
}
Binary file added codeceptJS/artifacts/artifact-test-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions codeceptJS/artifacts/artifact-test-text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this is test artifact content
10 changes: 9 additions & 1 deletion codeceptJS/codecept.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ const { setHeadlessWhen } = require('@codeceptjs/configure');

setHeadlessWhen(process.env.HEADLESS);

const tests = process.env.codecept_GROUP_TESTS === "quick"
? './todomvc-tests/todo-mvc_test.js'
: './todomvc-tests/**/*_test.js'

exports.config = {
tests: './todomvc-tests/**/*_test.js',
tests,
output: './output',
helpers: {
Playwright: {
video: true,
trace: true,
url: 'http://localhost',
waitForTimeout: 5000,
waitForNavigation: 'networkidle0',
Expand All @@ -33,6 +38,9 @@ exports.config = {
require: '@testomatio/reporter/lib/adapter/codecept',
apiKey: process.env.TESTOMATIO,
},
screenshotOnFail: {
enabled: false
}
},
bootstrap: null,
mocha: {},
Expand Down
25 changes: 13 additions & 12 deletions codeceptJS/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{
"name": "@codeceptjs/examples",
"version": "1.1.2",
"version": "1.1.3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "npx codeceptjs run",
"test:artifact": "npx codeceptjs run artifact-tests/**"
},
"keywords": [],
"author": "kaflan, davert",
"author": "kaflan, davert, mihaylukvv",
"license": "ISC",
"dependencies": {
"@testomatio/reporter": "^0.6.3",
"axios": "^0.19.2",
"check-tests": "^0.7.6",
"dotenv": "^8.6.0",
"playwright": "^1.23.0"
"@testomatio/reporter": "latest",
"axios": "^1.4.0",
"check-tests": "^0.8.16",
"dotenv": "^16.3.1",
"playwright": "^1.36.0"
},
"repository": {
"type": "git",
Expand All @@ -23,10 +24,10 @@
"url": "https://github.com/codecept-js/examples/issues"
},
"homepage": "https://github.com/codecept-js/examples#readme",
"description": "",
"description": "Running and Monitoring CodeceptJS Tests with TESTOMATIO Reporter",
"devDependencies": {
"@codeceptjs/configure": "^0.4.0",
"@codeceptjs/ui": "^0.2.0",
"codeceptjs": "^3.3.3"
"@codeceptjs/configure": "^0.10.0",
"@codeceptjs/ui": "^0.5.0",
"codeceptjs": "latest"
}
}
11 changes: 11 additions & 0 deletions codeceptJS/run-tests-and-check-results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

npx codeceptjs run > test-results.txt
fail_tests=$(grep -oE '\b[0-9]+\s+failed\b' test-results.txt | grep -oE '[0-9]+')
echo "Number of failed tests: $fail_tests"
if [ "$fail_tests" -gt 12 ]; then
echo "More than 12 failed tests. Exiting with error."
exit 1
else
exit 0
fi
22 changes: 22 additions & 0 deletions codeceptJS/tests-usage-examples/functions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const testomat = require('@testomatio/reporter');

Feature('Testomat functions');

Scenario('Upload file', async () => {
testomat.artifact('artifacts/artifact-test-text.txt');
});

Scenario('Upload image', async () => {
testomat.artifact({
path: 'artifacts/artifact-test-image.png',
});
});

Scenario('Add Step to report', async () => {
testomat.step('This is step message');
});

Scenario('Add log message to report', async () => {
testomat.log('This is log message');
testomat.log`This is log message with template literal`;
});
20 changes: 20 additions & 0 deletions codeceptJS/tests-usage-examples/logger.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const { logger, log } = require('@testomatio/reporter');

// console messages are added to report by default when import "logger" from reporter
// but to prevent unsused variable warning, you can call next code:
logger;

Feature('Logger @Sebd746ef');

Scenario('Intercept console logs @Tebebb252', async () => {
console.warn('This is warning message');
});

Scenario('Add own log message @T35d1887d', async () => {
const someObject = {
name: 'John',
surname: 'Doe',
age: 30,
};
log('This is log message', someObject);
});
4 changes: 4 additions & 0 deletions codeceptJS/todomvc-tests/create-todos_test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {testomatioLogger} = require('@testomatio/reporter');

Feature('@first Create Tasks @step:06 @smoke @story:12345')

Before(async ({ I, TodosPage }) => {
Expand All @@ -8,6 +10,8 @@ Before(async ({ I, TodosPage }) => {
* Happy Path tests
*/
Scenario('Create a new todo item', async ({ I, TodosPage }) => {
console.log('console log message');
testomatioLogger.info('testomatio info log message');
I.say('Given I have an empty todo list')

I.say('When I create a todo "foo"')
Expand Down
Loading

0 comments on commit 9b272a8

Please sign in to comment.