Skip to content

Commit

Permalink
setup jest environment and update gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
tjc234 committed Nov 18, 2023
1 parent 062a73c commit 1f1bcd1
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 5 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Python Test Workflow
name: Python and JS Test Workflow

on: [push, pull_request]

jobs:
build:
test-server:
runs-on: ubuntu-latest

steps:
Expand All @@ -15,11 +15,29 @@ jobs:
with:
python-version: 3.9

- name: Install dependencies
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests in requests.py with pytest
- name: Run Python tests with pytest
run: |
pytest testing/test_server.py
test-javascript:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 14

- name: Install JavaScript dependencies
run: npm install

- name: Run Jest tests
run: npm test
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
testing/__pycache__/test_server.cpython-310-pytest-7.4.3.pyc
# Python
__pycache__/
testing/__pycache__/
*.pyc

# Node.js
node_modules/
npm-debug.log

# Jest
coverage/
.venv/
*.log
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'jsdom',
};

24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "thebubblebots",
"version": "0.2.0",
"description": "checkers against ai",
"main": "index.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": "git+https://github.com/N1ckP3rsl3y/TheBubbleBots.git"
},
"keywords": [
"checkers",
"ai",
"server"
],
"author": "Nicholas Persley, Nicholas Robishaw, Elian Zamora-Rivera, Jeysen Angous, Tyler Chapp, Ibrahim Hmood",
"license": "MIT",
"bugs": {
"url": "https://github.com/N1ckP3rsl3y/TheBubbleBots/issues"
},
"homepage": "https://github.com/N1ckP3rsl3y/TheBubbleBots#readme"
}
24 changes: 24 additions & 0 deletions testing/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// __tests__/index.test.js

const { JSDOM } = require('jsdom');

// load the HTML content -- UPDATE LATER
const html = '<!DOCTYPE html><html><head></head><body><div id="gameboard"></div></body></html>';
const { window } = new JSDOM(html);
global.document = window.document;

// load the js file -- UPDATE PATH LATER
require('../src/index.js');

test('Board and pieces are drawn correctly', () => {
// assuming you have elements with data-testid attributes
const gameBoard = document.querySelector('[data-testid="game-board"]');
const redPiece = document.querySelector('[data-testid="red-piece"]');
const blackPiece = document.querySelector('[data-testid="black-piece"]');

// assert that the elements exist
expect(gameBoard).toBeTruthy();
expect(redPiece).toBeTruthy();
expect(blackPiece).toBeTruthy();

});

0 comments on commit 1f1bcd1

Please sign in to comment.