![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@genesislcap/foundation-testing
Advanced tools
foundation-testing
provides shared unit and e2e testing functionality.
The foundation-testing package is a comprehensive framework for implementing Unit Tests. Use it to ensure that your Genesis Web Application provides a seamless user experience by testing components, functions and user interactions across various scenarios.
The foundation-testing package is a comprehensive framework for implementing End-to-End (E2E) testing. use it to ensure that your Genesis Web Application provides a seamless user experience by testing workflows and user interactions across various scenarios.
playwright-bdd
, making it easier to define test scenarios and expectations in a human-readable format.You can unit-test specific logic by adding a test file alongside the source file.
logic.ts
logic.test.ts
If your test spans more than one file or is more of an end-to-end test, you may wish to add your test to your package's /test directory instead. An example structure might be:
├── src
│ └── logic.ts
│ └── logic.test.ts
│ └── component.ts
│ └── component.test.ts
├── test
│ └── e2e
│ └── baseline.e2e.ts
│ └── unit
│ └── baseline.test.ts
├── package.json
└── playwright.config.ts
The contents of your package's playwright.config.ts may include:
export { configDefaults as default } from '@genesislcap/foundation-testing/e2e';
If you need to customise configuration, you can do it as follows:
import { configDefaults } from '@genesislcap/foundation-testing/e2e';
export default {
...configDefaults,
// Any custom configuration here e.g. disabling the web server:
webServer: undefined,
};
If you need to customise JSDOM, you can create a jsdom.setup.ts file in your package directory:
// custom code
export * from '@genesislcap/foundation-testing/jsdom';
The test-related scripts to add to your package's package.json file may include:
"test": "genx test",
"test:single": "genx test --match connect.test.ts",
"test:single:browser": "genx test --browser --match connect.test.ts",
"test:single:browser:raw-match": "genx test --browser --raw-match --match ./**/connect.test.ts",
"test:select": "genx test --match '(connect|reconnectStrategy|kv).test.ts'",
"test:select:browser": "genx test --browser --match '(connect|reconnectStrategy|kv).test.ts'",
"test:glob": "genx test --match reconnectStrategy*.test.ts",
"test:glob:browser": "genx test --browser --match reconnectStrategy*.test.ts",
"test:coverage": "genx test --coverage",
"test:coverage:browser": "genx test --coverage --browser",
"test:e2e": "genx test --e2e",
"test:e2e:debug": "genx test --e2e --debug",
"test:e2e:ui": "genx test --e2e --interactive",
"test:unit:browser": "genx test --browser",
"test:unit:browser:watch": "genx test --browser --watch",
"test:unit:watch": "genx test --watch",
"test:debug": "genx test --debug"
The logic.test.ts usually uses createLogicSuite
, which is used to test function output given certain input
arguments. Based on user feedback, these arguments are now passed as an array by convention:
// logic.test.ts
import { createLogicSuite } from '@genesislcap/foundation-testing';
import { myFunction } from './logic';
const Suite = createLogicSuite('myFunction');
Suite('myFunction should provide expected results', ({ runCases }) => {
runCases(myFunction, [
[['1'], true],
[[123], true],
[['60%'], true],
[['$60'], false],
[['1.1'], false],
[[''], false],
[[true], false],
[[null], false],
[[undefined], false],
]);
});
Suite.run();
The component.test.ts or any test that directly or indirectly makes use of the DI uses createComponentSuite
. Apart from setting up and tearing down your element fixture with a wrapping design system and DI container, this util also allows you to provide DI container mocks, which are required for certain testing flows.
// component.test.ts
import { Connect } from '@genesislcap/foundation-comms';
import { ConnectMock } from '@genesislcap/foundation-comms/testing';
import { assert, createComponentSuite, Registration } from '@genesislcap/foundation-testing';
import { MyComponent } from './component';
/**
* As we're using tag name in the Suite, we hold a reference to avoid tree shaking.
*/
MyComponent;
/**
* Create mock
*/
const connectMock = new ConnectMock();
connectMock.nextMetadata = {
FIELD: [
{
NAME: 'foo',
TYPE: 'bar',
},
],
};
/**
* Resister mock instance
*/
const mocks = [Registration.instance(Connect, connectMock)];
const Suite = createComponentSuite<MyComponent>(
'MyComponent',
'my-component', // < or () => myComponent() if your component is composeable
null,
mocks,
);
Suite('Can be created in the DOM', async ({ element }) => {
assert.ok(element);
});
Suite('Connect is mocked in the container', async ({ container }) => {
const serviceMock = container.get(Connect);
assert.instance(serviceMock, ConnectMock);
});
Suite('Attr changes update internals as expected', async ({ element }) => {
element.setAttribute('resource-name', 'ALL_USERS');
assert.match(element.optionsHash, /ALL_USERS/);
element.setAttribute('order-by', 'USERNAME');
assert.match(element.optionsHash, /USERNAME/);
});
Suite('Connect.getMetadata returns expected nextMetadata', async ({ container }) => {
const serviceMock = container.get(Connect) as ConnectMock;
/**
* Assert base case
*/
let serviceMeta = await serviceMock.getMetadata('someResource');
assert.is(serviceMeta.FIELD[0].NAME, 'foo');
/**
* Apply next and assert
*/
const metadata = {
FIELD: [
{
NAME: 'hello',
TYPE: 'world',
},
],
};
serviceMock.nextMetadata = {
...metadata,
};
serviceMeta = await serviceMock.getMetadata('someResource');
assert.equal(serviceMeta, {
...metadata,
});
// TODO: Trigger and cross check component reactions to underlying data changes
});
Suite.run();
The baseline.e2e.ts uses playwright
; test cases have access to the fixtures provided during set-up.
import { test, expect } from '@genesislcap/foundation-testing/e2e';
test('baseline test', async ({ page }) => {
await page.goto('https://playwright.dev/');
const name = await page.innerText('.navbar__title');
expect(name).toBe('Playwright');
});
We will be adding more details on E2E in future updates.
To enable this module in your application, follow the steps below.
@genesislcap/foundation-testing
as a dependency in your package.json
file. Whenever you change the dependencies of your project, ensure you run the $ npm run bootstrap
command again. You can find more information in the package.json basics page.{
"dependencies": {
"@genesislcap/foundation-testing": "latest"
},
}
Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact Genesis Global for more details.
Genesis low-code platform
FAQs
Genesis Foundation Testing
The npm package @genesislcap/foundation-testing receives a total of 12 weekly downloads. As such, @genesislcap/foundation-testing popularity was classified as not popular.
We found that @genesislcap/foundation-testing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.