Skip to content

feat(tests): add firefox to vitest browser tests #10571

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

Merged
merged 4 commits into from
May 8, 2025
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

## [next]

- feat(tests): add firefox to vitest browser tests [#10571](https://github.com/fabricjs/fabric.js/pull/10571)
- refactor(tests): move to data url tests from qunit to playwright [#10581](https://github.com/fabricjs/fabric.js/pull/10581)
- chore(TS): remove @ts-nocheck in straighten.ts [#10572](https://github.com/fabricjs/fabric.js/pull/10572)
- refactor(tests): move svg export visual tests to playwright [#10575](https://github.com/fabricjs/fabric.js/pull/10575)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@
"build-tests": "rollup -c ./rollup.test.config.js",
"test:vitest": "vitest --run --project unit-node",
"test:vitest:chromium": "vitest --run --project unit-chromium",
"test:vitest:firefox": "vitest --run --project unit-firefox",
"test:vitest:all": "vitest --run",
"test": "npm run cli -- test",
"sandbox": "npm run sandboxscript -- sandbox",
35 changes: 30 additions & 5 deletions src/shapes/IText/ITextBehavior.test.ts
Original file line number Diff line number Diff line change
@@ -42,34 +42,59 @@ describe('text imperative changes', () => {
matchTextStateSnapshot(iText);
});

it('insertChars', async () => {
it('insertChars', async (context) => {
context.skip(
!!context.task.file.projectName?.includes('firefox'),
'Firefox delivers different snapshot',
);

const iText = await create();
iText.insertChars('ab', undefined, 1);
expect(iText.text).toBe('tabest');
matchTextStateSnapshot(iText);
});

it('insertChars and removes chars', async () => {
it('insertChars and removes chars', async (context) => {
context.skip(
!!context.task.file.projectName?.includes('firefox'),
'Firefox delivers different snapshot',
);

const iText = await create();
iText.insertChars('ab', undefined, 1, 2);
expect(iText.text).toBe('tabst');
matchTextStateSnapshot(iText);
});

it('insertChars and removes chars', async () => {
it('insertChars and removes chars', async (context) => {
context.skip(
!!context.task.file.projectName?.includes('firefox'),
'Firefox delivers different snapshot',
);

const iText = await create();
iText.insertChars('ab', undefined, 1, 4);
expect(iText.text).toBe('tab');
matchTextStateSnapshot(iText);
});

it('insertChars handles new lines correctly', async () => {
it('insertChars handles new lines correctly', async (context) => {
context.skip(
!!context.task.file.projectName?.includes('firefox'),
'Firefox delivers different snapshot',
);

const iText = await create();
iText.insertChars('ab\n\n', undefined, 1);
matchTextStateSnapshot(iText);
});

it('insertChars can accept some style for the new text', async () => {
it('insertChars can accept some style for the new text', async (context) => {
context.skip(
!!context.task.file.projectName?.includes('firefox'),
'Firefox delivers different snapshot',
);

const iText = await create();
iText.insertChars(
'ab\n\na',
2 changes: 1 addition & 1 deletion tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"types": [],
"types": ["@vitest/browser/providers/playwright"],
"noEmit": true,
"allowSyntheticDefaultImports": true,
"paths": {
19 changes: 19 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
@@ -48,6 +48,25 @@ export default defineConfig({
name: 'unit-chromium',
},
},
{
extends: true,
test: {
browser: {
provider: 'playwright',
enabled: true,
headless: true,
instances: [
{
browser: 'firefox',
context: {
hasTouch: true,
},
},
],
},
name: 'unit-firefox',
},
},
],
include: [
'src/**/*.test.{ts,tsx}',

Unchanged files with check annotations Beta

* @protected
* @param {Object} [options] Options object
*/
protected _setOptions(options: any = {}) {

Check warning on line 9 in src/CommonMethods.ts

GitHub Actions / lint

Unexpected any. Specify a different type
for (const prop in options) {
this.set(prop, options[prop]);
}
/**
* @private
*/
_setObject(obj: Record<string, any>) {

Check warning on line 18 in src/CommonMethods.ts

GitHub Actions / lint

Unexpected any. Specify a different type
for (const prop in obj) {
this._set(prop, obj[prop]);
}
object: FabricObject,
index: number,
array: FabricObject[],
) => any,

Check warning on line 96 in src/Collection.ts

GitHub Actions / lint

Unexpected any. Specify a different type
) {
this.getObjects().forEach((object, index, objects) =>
callback(object, index, objects),
export const SVG = 'svg';
export class ClassRegistry {
declare [JSON]: Map<string, any>;

Check warning on line 19 in src/ClassRegistry.ts

GitHub Actions / lint

Unexpected any. Specify a different type
declare [SVG]: Map<string, any>;

Check warning on line 20 in src/ClassRegistry.ts

GitHub Actions / lint

Unexpected any. Specify a different type
constructor() {
this[JSON] = new Map();
return constructor;
}
setClass(classConstructor: any, classType?: string) {

Check warning on line 39 in src/ClassRegistry.ts

GitHub Actions / lint

Unexpected any. Specify a different type
if (classType) {
this[JSON].set(classType, classConstructor);
} else {
}
}
getSVGClass(SVGTagName: string): any {

Check warning on line 50 in src/ClassRegistry.ts

GitHub Actions / lint

Unexpected any. Specify a different type
return this[SVG].get(SVGTagName);
}
setSVGClass(classConstructor: any, SVGTagName?: string) {

Check warning on line 54 in src/ClassRegistry.ts

GitHub Actions / lint

Unexpected any. Specify a different type
this[SVG].set(
SVGTagName ?? classConstructor.type.toLowerCase(),
classConstructor,
* @returns a wrapped fromObject function for the object
*/
export const originUpdaterWrapper = <T extends FabricObject = FabricObject>(
originalFn: (...args: any[]) => Promise<T>,

Check warning on line 21 in extensions/data_updaters/origins/index.ts

GitHub Actions / lint

Unexpected any. Specify a different type
defaultOriginX: TOriginX = 'left',
defaultOriginY: TOriginY = 'top',
): ((...args: any[]) => Promise<T>) =>

Check warning on line 24 in extensions/data_updaters/origins/index.ts

GitHub Actions / lint

Unexpected any. Specify a different type
async function (this: T, serializedObject, ...args) {
// we default to left and top because those are defaults before deprecation
const { originX = defaultOriginX, originY = defaultOriginY } =