-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add unit test for eslint configs
The commit adds a unit test for the eslint configurations and properly formats our tests.
- Loading branch information
Showing
5 changed files
with
114 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { it, describe, expect } from 'vitest' | ||
import { getAdditionalConfigAndDependencies } from '../utils/renderEslint' | ||
|
||
describe('renderEslint', () => { | ||
it('should get additional dependencies and config with no test flags', () => { | ||
const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ | ||
needsCypress: false, | ||
needsCypressCT: false, | ||
needsPlaywright: false | ||
}) | ||
expect(additionalConfig).toStrictEqual({}) | ||
expect(additionalDependencies).toStrictEqual({}) | ||
}) | ||
|
||
it('should get additional dependencies and config with for cypress', () => { | ||
const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ | ||
needsCypress: true, | ||
needsCypressCT: false, | ||
needsPlaywright: false | ||
}) | ||
expect(additionalConfig.overrides[0].files).toStrictEqual([ | ||
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', | ||
'cypress/support/**/*.{js,ts,jsx,tsx}' | ||
]) | ||
expect(additionalConfig.overrides[0].extends).toStrictEqual(['plugin:cypress/recommended']) | ||
expect(additionalDependencies['eslint-plugin-cypress']).not.toBeUndefined() | ||
}) | ||
|
||
it('should get additional dependencies and config with for cypress with component testing', () => { | ||
const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ | ||
needsCypress: true, | ||
needsCypressCT: true, | ||
needsPlaywright: false | ||
}) | ||
expect(additionalConfig.overrides[0].files).toStrictEqual([ | ||
'**/__tests__/*.{cy,spec}.{js,ts,jsx,tsx}', | ||
'cypress/e2e/**/*.{cy,spec}.{js,ts,jsx,tsx}', | ||
'cypress/support/**/*.{js,ts,jsx,tsx}' | ||
]) | ||
expect(additionalConfig.overrides[0].extends).toStrictEqual(['plugin:cypress/recommended']) | ||
expect(additionalDependencies['eslint-plugin-cypress']).not.toBeUndefined() | ||
}) | ||
|
||
it('should get additional dependencies and config with for playwright', () => { | ||
const { additionalConfig, additionalDependencies } = getAdditionalConfigAndDependencies({ | ||
needsCypress: false, | ||
needsCypressCT: false, | ||
needsPlaywright: true | ||
}) | ||
expect(additionalConfig.overrides[0].files).toStrictEqual([ | ||
'e2e/**/*.{test,spec}.{js,ts,jsx,tsx}' | ||
]) | ||
expect(additionalConfig.overrides[0].extends).toStrictEqual(['plugin:playwright/recommended']) | ||
expect(additionalDependencies['eslint-plugin-playwright']).not.toBeUndefined() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters