Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jochen-testingbot committed Sep 12, 2024
0 parents commit adea1f0
Show file tree
Hide file tree
Showing 8 changed files with 4,157 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: NodeJS Tests

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- run: npm ci
- run: npm test
env:
TESTINGBOT_KEY: ${{ secrets.TESTINGBOT_KEY }}
TESTINGBOT_SECRET: ${{ secrets.TESTINGBOT_SECRET }}
91 changes: 91 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# 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

# 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

# IDEs and editors
.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
.sass-cache
connect.lock
typings

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*


# Dependency directories
node_modules/
jspm_packages/

# 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

# Lerna
lerna-debug.log

# System Files
.DS_Store
Thumbs.db
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) TestingBot

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## TestingBot - JestJS Example

TestingBot offers an online grid of browsers and mobile devices for running automated tests using Jest.
This example repository demonstrates how to use Jest to execute Selenium WebDriver tests in parallel across multiple browsers on TestingBot.

### Environment Setup

1. Global Dependencies
* Install [Node.js](https://nodejs.org/en/)
* Or Install Node.js with [Homebrew](http://brew.sh/)
```
$ brew install node
```
2. TestingBot Credentials
* In the terminal export your TestingBot Credentials as environmental variables:
```
$ export TESTINGBOT_KEY=<your TestingBot Key>
$ export TESTINGBOT_SECRET=<your TestingBot Secret>
```
3. Project Dependencies
* Install Node modules
```
$ npm install
```
### Running Tests
* Run a Jest test:
```
$ npm test
```
You will see the test result in the [TestingBot Dashboard](https://testingbot.com/members/)
### Resources
##### [TestingBot Jest Documentation](https://testingbot.com/support/getting-started/jest.html)
##### [SeleniumHQ Documentation](http://www.seleniumhq.org/docs/)
##### [Jest Documentation](https://jestjs.io/docs/getting-started/)
36 changes: 36 additions & 0 deletions __tests__/single.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const webdriver = require("selenium-webdriver")

describe("TestingBot example test", () => {
let driver

beforeAll(() => {
const tbKey = process.env.TESTINGBOT_KEY
const tbSecret = process.env.TESTINGBOT_SECRET
const capabilities = {
'platformName' : 'WIN10',
'browserName' : 'chrome',
'browserVersion' : 'latest',
'tb:options': {
'name': 'Jest Sample Test'
}
}
driver = new webdriver.Builder()
.usingServer(`https://${tbKey}:${tbSecret}@hub.testingbot.com/wd/hub`)
.withCapabilities(capabilities)
.build()
})

afterAll(async () => {
await driver.quit()
})

test("example test", async () => {
await driver.get("https://testingbot.com")

await driver.findElement(webdriver.By.css("body > div.bigHeader.home > nav > div > div.navigation-actions.is-desktop > a.button.button-trial")).click()

expect(await driver.getCurrentUrl()).toBe(
"https://testingbot.com/users/sign_up"
)
})
})
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
testEnvironment: 'node',
testTimeout: 60000, // Extend timeout for Selenium tests
coverageProvider: "v8",
maxConcurrency: 5,
maxWorkers: 5,
testPathIgnorePatterns: ["/node_modules/"]
};
Loading

0 comments on commit adea1f0

Please sign in to comment.