Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add flaky tests for react + flask #619

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions flask/src/test/test_flaky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import unittest
import random
import time

class FlakyTestExample(unittest.TestCase):
def test_flaky_function(self):
# Simulating a function that sometimes fails
result = random.choice([True, True, False, False])

# Adding delay to simulate randomness further
time.sleep(random.uniform(0.1, 0.5))

self.assertTrue(result, "The result was not True, indicating a flaky behavior")

if __name__ == "__main__":
unittest.main()
15 changes: 15 additions & 0 deletions react/src/tests/Flaky.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe("Flaky Test Example", () => {
test("sometimes passes, sometimes fails", () => {
// Simulating a function that sometimes returns true and sometimes false
const result = Math.random() > 0.25;

// Adding a small delay to make it even flakier
return new Promise((resolve) => {
setTimeout(() => {
expect(result).toBe(true);
resolve();
}, Math.random() * 500);
});
});
});

Loading