Skip to content

Commit

Permalink
Re-work integration tests and add test linting
Browse files Browse the repository at this point in the history
  • Loading branch information
devpow112 committed Oct 24, 2024
1 parent fb6a387 commit cb148f7
Show file tree
Hide file tree
Showing 27 changed files with 388 additions and 235 deletions.
22 changes: 11 additions & 11 deletions d2l-test-reporting.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
"experience": "Test Framework",
"tool": "Test Reporting",
"ignorePatterns": [
"**/mocha-3.test.js",
"**/playwright-3.test.js",
"**/playwright.setup.js",
"**/playwright.teardown.js",
"**/web-test-runner-3.test.js"
"**/tests/mocha/reporter-3.test.js",
"**/tests/playwright/reporter-3.test.js",
"**/tests/playwright/setup.js",
"**/tests/playwright/teardown.js",
"**/tests/web-test-runner/reporter-3.test.js"
],
"overrides": [
{
"pattern": "**/mocha-1.test.js",
"pattern": "**/tests/mocha/reporter-1.test.js",
"type": "ui",
"tool": "Mocha 1 Test Reporting"
},
{
"pattern": "**/mocha-2.test.js",
"pattern": "**/tests/mocha/reporter-2.test.js",
"experience": "Mocha 2 Test Framework"
},
{
"pattern": "**/playwright-1.test.js",
"pattern": "**/tests/playwright/reporter-1.test.js",
"experience": "Playwright 1 Test Framework",
"tool": "Playwright 1 Test Reporting"
},
{
"pattern": "**/playwright-2.test.js",
"pattern": "**/tests/playwright/reporter-2.test.js",
"type": "visual diff",
"experience": "Playwright 2 Test Framework"
},
{
"pattern": "**/web-test-runner-1.test.js",
"pattern": "**/tests/web-test-runner/reporter-1.test.js",
"experience": "WebTestRunner 1 Test Framework",
"tool": "WebTestRunner 1 Test Reporting"
},
{
"pattern": "**/web-test-runner-2.test.js",
"pattern": "**/tests/web-test-runner/reporter-2.test.js",
"type": "accessibility",
"experience": "WebTestRunner 2 Test Framework"
}
Expand Down
120 changes: 117 additions & 3 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"lodash": "^4",
"minimatch": "^10",
"mocha": "^10",
"playwright-core": "^1.44.1"
"playwright-core": "^1.48"
},
"devDependencies": {
"@playwright/test": "^1",
Expand All @@ -65,8 +65,10 @@
"d2l-license-checker": "^4",
"eslint": "^8",
"eslint-config-brightspace": "^1",
"eslint-plugin-mocha": "^10",
"eslint-plugin-playwright": "^2",
"npm-run-all": "^4",
"playwright": "^1.44.1",
"playwright": "^1.48",
"sinon": "^19"
}
}
17 changes: 16 additions & 1 deletion test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
{
"extends": "brightspace/testing-config"
"plugins": [
"mocha"
],
"extends": [
"brightspace/testing-config",
"plugin:mocha/recommended"
],
"env": {
"mocha": true
},
"rules": {
// fails if `.only` is used
"mocha/no-exclusive-tests": "error",
"mocha/no-mocha-arrows": "off",
"no-console": "off"
}
}
2 changes: 1 addition & 1 deletion test/integration/data/configs/mocha.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
spec: 'test/integration/data/mocha-*.test.js',
spec: 'test/integration/data/tests/mocha/*.test.js',
retries: 3,
reporter: 'src/reporters/mocha.cjs',
reporterOptions: [
Expand Down
14 changes: 7 additions & 7 deletions test/integration/data/configs/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ export default defineConfig({
],
retries: 3,
fullyParallel: true,
testDir: '../',
testMatch: 'playwright-*.test.js',
testDir: '../tests/playwright/',
testMatch: '*.test.js',
use: deviceTypeChrome,
globalSetup: '../playwright.global.setup.js',
globalTeardown: '../playwright.global.teardown.js',
globalSetup: '../tests/playwright/global.setup.js',
globalTeardown: '../tests/playwright/global.teardown.js',
projects: [{
name: 'setup',
testMatch: 'playwright.setup.js',
testMatch: 'setup.js',
teardown: 'teardown'
}, {
name: 'teardown',
testMatch: 'playwright.teardown.js'
testMatch: 'teardown.js'
}, {
name: 'chromium',
dependencies: ['setup']
}, {
name: 'firefox',
testMatch: 'playwright-2.test.js',
testMatch: 'reporter-2.test.js',
use: deviceTypeFirefox,
dependencies: ['setup'],
metadata: {
Expand Down
7 changes: 5 additions & 2 deletions test/integration/data/configs/web-test-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ export default {
verbose: true
})
],
files: './test/integration/data/web-test-runner-1.test.js',
files: [
'./test/integration/data/tests/web-test-runner/reporter-1.test.js',
'./test/integration/data/tests/web-test-runner/reporter-3.test.js'
],
groups: [{
name: 'group 1',
files: './test/integration/data/web-test-runner-2.test.js',
files: './test/integration/data/tests/web-test-runner/reporter-2.test.js',
browsers: [
puppeteerLauncher({ launchOptions: { headless: 'new' } }),
playwrightLauncher({ product: 'firefox' })
Expand Down
3 changes: 0 additions & 3 deletions test/integration/data/playwright.global.setup.js

This file was deleted.

3 changes: 0 additions & 3 deletions test/integration/data/playwright.global.teardown.js

This file was deleted.

5 changes: 5 additions & 0 deletions test/integration/data/tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"rules": {
"mocha/no-skipped-tests": "off"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ const delay = (ms = 50) => {
return new Promise(resolve => setTimeout(resolve, ms));
};

describe('reporter tests 1', () => {
describe('reporter 1', () => {
let count = 0;

before(async() => { await delay(250); });

beforeEach(async() => { await delay(250); });

it('test', async() => { await delay(); });
it('passed', async() => { await delay(); });

it.skip('skipped test', () => {});
it.skip('skipped', () => {});

it('flaky test', async() => {
it('flaky', async() => {
if (count < 2) {
await delay();

Expand All @@ -25,7 +25,7 @@ describe('reporter tests 1', () => {
await delay();
});

it('failed test', () => { throw new Error('fail'); });
it('failed', () => { throw new Error('fail'); });

afterEach(async() => { await delay(250); });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ const delay = (ms = 50) => {
return new Promise(resolve => setTimeout(resolve, ms));
};

describe('reporter tests 2', () => {
describe('reporter 2', () => {
let count = 0;

before(async() => { await delay(250); });

beforeEach(async() => { await delay(250); });

it('test', async() => { await delay(); });
it('passed', async() => { await delay(); });

it.skip('skipped test', () => {});
it.skip('skipped', () => {});

it('flaky test', async() => {
it('flaky', async() => {
if (count < 2) {
await delay();

Expand All @@ -25,7 +25,7 @@ describe('reporter tests 2', () => {
await delay();
});

it('failed test', () => { throw new Error('fail'); });
it('failed', () => { throw new Error('fail'); });

afterEach(async() => { await delay(250); });

Expand Down
Loading

0 comments on commit cb148f7

Please sign in to comment.