Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,12 @@ ui-test:
ui-test-screens:
$(NPM_BIN) --prefix awx/ui install
$(NPM_BIN) run --prefix awx/ui pretest
$(NPM_BIN) run --prefix awx/ui test-screens --runInBand
$(NPM_BIN) run --prefix awx/ui test-screens

ui-test-general:
$(NPM_BIN) --prefix awx/ui install
$(NPM_BIN) run --prefix awx/ui pretest
$(NPM_BIN) run --prefix awx/ui/ test-general --runInBand
$(NPM_BIN) run --prefix awx/ui/ test-general

HEADLESS ?= no
ifeq ($(HEADLESS), yes)
Expand Down
8 changes: 4 additions & 4 deletions awx/ui/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ class Organizations extends InstanceGroupsMixin(NotificationsMixin(Base)) {
export default Organizations;
```

**Testing** - The easiest way to mock the api module in tests is to use jest's [automatic mock](https://jestjs.io/docs/en/es6-class-mocks#automatic-mock). This syntax will replace the class with a mock constructor and mock out all methods to return undefined by default. If necessary, you can still override these mocks for specific tests. See the example below.
**Testing** - The easiest way to mock the api module in tests is to use Vitest's [automatic mock](https://vitest.dev/api/vi#vi-mock). This syntax will replace the class with a mock constructor and mock out all methods to return undefined by default. If necessary, you can still override these mocks for specific tests. See the example below.

Example of mocking a specific method for every test in a suite:

```javascript
import { OrganizationsAPI } from '../../../../src/api';

// Mocks out all available methods. Comparable to:
// OrganizationsAPI.readAccessList = jest.fn();
// OrganizationsAPI.readAccessList = vi.fn();
// but for every available method
jest.mock('../../../../src/api');
vi.mock('../../../../src/api');

// Return a specific mock value for the readAccessList method
beforeEach(() => {
Expand All @@ -122,7 +122,7 @@ beforeEach(() => {

// Reset mocks
afterEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
});

...
Expand Down
35 changes: 0 additions & 35 deletions awx/ui/config/jest/babelTransform.js

This file was deleted.

20 changes: 0 additions & 20 deletions awx/ui/config/jest/cssModulesTransform.js

This file was deleted.

16 changes: 0 additions & 16 deletions awx/ui/config/jest/cssTransform.js

This file was deleted.

40 changes: 0 additions & 40 deletions awx/ui/config/jest/fileTransform.js

This file was deleted.

22 changes: 0 additions & 22 deletions awx/ui/config/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,6 @@ function getWebpackAliases(options = {}) {
}
}

/**
* Get jest aliases based on the baseUrl of a compilerOptions object.
*
* @param {*} options
*/
function getJestAliases(options = {}) {
const baseUrl = options.baseUrl;

if (!baseUrl) {
return {};
}

const baseUrlResolved = path.resolve(paths.appPath, baseUrl);

if (path.relative(paths.appPath, baseUrlResolved) === '') {
return {
'^src/(.*)$': '<rootDir>/src/$1',
};
}
}

function getModules() {
// Check if TypeScript is setup
const hasTsConfig = fs.existsSync(paths.appTsConfig);
Expand Down Expand Up @@ -127,7 +106,6 @@ function getModules() {
return {
additionalModulePaths: additionalModulePaths,
webpackAliases: getWebpackAliases(options),
jestAliases: getJestAliases(options),
hasTsConfig,
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { TextEncoder, TextDecoder } = require('util');
const { TextEncoder, TextDecoder } = require('node:util');

if (typeof globalThis.TextEncoder === 'undefined') {
globalThis.TextEncoder = TextEncoder;
Expand Down
4 changes: 2 additions & 2 deletions awx/ui/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

Browser tests for the Ascender UI, driven by [Playwright](https://playwright.dev).

These cover what the jest suite in `awx/ui/src` cannot. That suite runs in jsdom,
These cover what the Vitest suite in `awx/ui/src` cannot. That suite runs in jsdom,
which does not faithfully reproduce event bubbling through the DOM, focus, or
anything rendered through a portal. #742 is the worked example: a jest test for
anything rendered through a portal. #742 is the worked example: a unit test for
"picking a job navigates" passed against code where the click did nothing in
every real browser.

Expand Down
4 changes: 2 additions & 2 deletions awx/ui/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import globals from 'globals';
export default defineConfig([
{
ignores: [
'jest.*.js',
'vitest.config.mjs',
'webpack.*.js',
'etc/**',
'coverage/**',
Expand Down Expand Up @@ -59,7 +59,7 @@ export default defineConfig([
globals: {
...globals.browser,
...globals.node,
...globals.jest,
...globals.vitest,
},
},
settings: {
Expand Down
Loading