Skip to content

When running vitest it will fail if there is a reference to the figma global outside of the test function #66

Description

@gavinmcfarland

This happens because the test runs both inside node and figma. Currently I am disabling it by creating a setup file that creates a dummy proxy for the figma global.

if (typeof globalThis.figma === 'undefined') {
	;(globalThis as any).figma = new Proxy(
		{},
		{
			get: (target, prop) => {
				if (!(prop in target)) {
					target[prop] = new Proxy(() => {}, {
						apply: () => undefined,
						get: () => () => {}, // return no-op function for any method
					})
				}
				return target[prop]
			},
		},
	)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions