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

Migrate jest js to ts #38

Closed
wants to merge 19 commits into from
Closed
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
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions webapp/e2e/jest.config.js

This file was deleted.

9 changes: 9 additions & 0 deletions webapp/e2e/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Config } from '@jest/types';

const config: Config.InitialOptions = {
testMatch: ["**/steps/*.ts"],
testTimeout: 30000,
setupFilesAfterEnv: ["expect-puppeteer"]
};

export default config;
52 changes: 0 additions & 52 deletions webapp/e2e/steps/register-form.steps.js

This file was deleted.

29 changes: 29 additions & 0 deletions webapp/e2e/steps/register-form.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import playwright from 'playwright';
import { test, expect } from 'playwright/test';

let page: playwright.Page;

test.describe('Register form', async () => {
test.beforeAll(async () => {
await page.goto('http://localhost:3000', { waitUntil: 'networkidle' });
});

test('The user is not registered in the site', async ({ page }) => {
const username: string = 'pablo';
const password: string = 'pabloasw';

await expect(page.locator('#register-button')).toBeVisible();
await page.click('#register-button');

await page.fill('#username', username);
await page.fill('#password', password);
await page.click('#submit-button');

await expect(page.locator('#confirmation-message')).toHaveText('User added successfully');
});

// eslint-disable-next-line no-empty-pattern
test.afterAll(async () => {

});
});
19 changes: 0 additions & 19 deletions webapp/e2e/test-environment-setup.js

This file was deleted.

18 changes: 18 additions & 0 deletions webapp/e2e/test-environment-setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MongoMemoryServer } from 'mongodb-memory-server';

let mongoserver: MongoMemoryServer | undefined;

async function startServer(): Promise<void> {
console.log('Starting MongoDB memory server...');
mongoserver = await MongoMemoryServer.create();
const mongoUri: string = mongoserver.getUri();
process.env.MONGODB_URI = mongoUri;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let userservice: any | undefined = await import("../../users/userservice/user-service");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let authservice: any | undefined = await import("../../users/authservice/auth-service");
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let gatewayservice: any | undefined = await import("../../gatewayservice/gateway-service");
}

startServer();
Loading
Loading