Skip to content

Commit

Permalink
initialize examples-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
kobenguyent committed Mar 26, 2024
0 parents commit 2d20c41
Show file tree
Hide file tree
Showing 22 changed files with 835 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Acceptance Tests

on:
push:
branches:
- master
- main
pull_request:
branches:
- '**'

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.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: Run tests
run: |
npm i && npx playwright install chromium
npx codeceptjs run --steps
64 changes: 64 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
output
# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

package-lock.json
.idea
76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
This repo contains tests for TodoMVC application written with Typescript.
Tests can be executed via different helpers.

![](todo.png)

# Installation

This is a playground for your first steps in testing with Typescript, so instead of installing it from NPM it is recommended to clone it from repo instead and then install the dependencies:

```
git clone git@github.com:codecept-js/examples-ts.git codeceptjs-examples-ts && cd codeceptjs-examples-ts && npm i
```

This will install CodeceptJS with Puppeteer, WebdriverIO & TestCafe packages.

# Running Tests

The default helper is Playwright.

## Playwright

Use `codecept.conf.ts` to run tests with Playwright:

```
npx codeceptjs run --steps
```

## Puppeteer

Use `codecept.puppeteer.conf.ts` to run tests with Puppeteer:

```
npx codeceptjs run --steps -c codecept.puppeteer.conf.ts
```


## WebdriverIO

Use `codecept.webdriver.conf.ts` to run tests with WebdriverIO in Chrome:

```
npx codeceptjs run -c codecept.webdriver.conf.ts --steps
```

## TestCafe

Use `codecept.testcafe.conf.ts` to run tests with TestCafe in Chrome:

```
npx codeceptjs run -c codecept.testcafe.conf.ts --steps
```

## Headless Mode

Run tests in headless mode:

```
HEADLESS=true npx codeceptjs run --steps
```

## Parallel Execution

Run tests in parallel with 3 workers:

```
npx codeceptjs run-workers 3
```

## Credits

Created as part of codepress by Stefan Huber.
Maintained by CodeceptJS Team.

## LICENSE

MIT
35 changes: 35 additions & 0 deletions codecept.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { setHeadlessWhen } = require('@codeceptjs/configure');

setHeadlessWhen(process.env.HEADLESS);

exports.config = {
tests: './todomvc-tests/**/*_test.ts',
output: './output',
helpers: {
Playwright: {
url: 'http://localhost',
waitForTimeout: 5000,
show: false,
},

REST: {},

CustomHelper: {
require: './todomvc-tests/helpers/custom.helper.ts'
}
},

gherkin: {
features: './todomvc-tests/features/*.feature',
steps: [
'./todomvc-tests/step-definitions/create-todos.steps.ts'
]
},

include: {
TodosPage: './todomvc-tests/pages/todos.page.ts'
},
bootstrap: null,
mocha: {},
name: 'codecept demo tests'
}
37 changes: 37 additions & 0 deletions codecept.puppeteer.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { setHeadlessWhen } = require('@codeceptjs/configure');

setHeadlessWhen(process.env.HEADLESS);

exports.config = {
tests: './todomvc-tests/**/*_test.ts',
output: './output',
helpers: {
Puppeteer: {
url: 'http://localhost',
waitForTimeout: 5000,
waitForNavigation: 'networkidle0',
waitForAction: 0,
show: true,
},

REST: {},

CustomHelper: {
require: './todomvc-tests/helpers/custom.helper.ts'
}
},

gherkin: {
features: './todomvc-tests/features/*.feature',
steps: [
'./todomvc-tests/step-definitions/create-todos.steps.ts'
]
},

include: {
TodosPage: './todomvc-tests/pages/todos.page.ts'
},
bootstrap: null,
mocha: {},
name: 'codecept demo tests'
}
35 changes: 35 additions & 0 deletions codecept.testcafe.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const { setHeadlessWhen } = require('@codeceptjs/configure');

setHeadlessWhen(process.env.HEADLESS);

exports.config = {
tests: './todomvc-tests/**/*_test.ts',
output: './output',
helpers: {
TestCafe: {
url: 'http://localhost',
browser: 'chrome',
show: true,
},

REST: {},

CustomHelper: {
require: './todomvc-tests/helpers/custom.helper.ts'
}
},

gherkin: {
features: './todomvc-tests/features/*.feature',
steps: [
'./todomvc-tests/step-definitions/create-todos.steps.ts'
]
},

include: {
TodosPage: './todomvc-tests/pages/todos.page.ts'
},
bootstrap: null,
mocha: {},
name: 'codecept demo tests'
}
42 changes: 42 additions & 0 deletions codecept.webdriver.conf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const { setHeadlessWhen } = require('@codeceptjs/configure');

setHeadlessWhen(process.env.HEADLESS);

exports.config = {
tests: './todomvc-tests/**/*_test.ts',
output: './output',
helpers: {
WebDriver: {
url: 'http://localhost',
browser: 'chrome',
},

REST: {},

CustomHelper: {
require: './todomvc-tests/helpers/custom.helper.ts'
}
},

gherkin: {
features: './todomvc-tests/features/*.feature',
steps: [
'./todomvc-tests/step-definitions/create-todos.steps.ts'
]
},

include: {
TodosPage: './todomvc-tests/pages/todos.page.ts'
},

plugins: {
wdio: {
enabled: true,
services: ['selenium-standalone']
}
},

bootstrap: null,
mocha: {},
name: 'codecept demo tests'
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@codeceptjs/examples-ts",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "kobenguyent, davert",
"license": "ISC",
"dependencies": {
"ts-node": "10.9.2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/codeceptjs/examples-ts.git"
},
"bugs": {
"url": "https://github.com/codeceptjs/examples-ts.git/issues"
},
"homepage": "https://github.com/codeceptjs/examples-ts.git#readme",
"description": "",
"devDependencies": {
"@codeceptjs/configure": "^0.5.0",
"@codeceptjs/ui": "^0.2.0",
"@types/node": "^20.11.30",
"@wdio/selenium-standalone-service": "^5.16.10",
"codeceptjs": "3.5.12",
"playwright": "1.41.2",
"puppeteer": "^2.0.0",
"testcafe": "^1.7.0",
"webdriverio": "^5.16.11"
}
}
12 changes: 12 additions & 0 deletions steps.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/// <reference types='codeceptjs' />
type TodosPage = typeof import('./todomvc-tests/pages/todos.page');
type CustomHelper = import('./todomvc-tests/helpers/custom.helper');

declare namespace CodeceptJS {
interface SupportObject { I: I, current: any, TodosPage: TodosPage }
interface Methods extends Playwright, REST, CustomHelper {}
interface I extends WithTranslation<Methods> {}
namespace Translation {
interface Actions {}
}
}
Binary file added todo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions todomvc-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Testing "Create TODOs" using page objects

- Create single todo
- Create multiple todos
Loading

0 comments on commit 2d20c41

Please sign in to comment.