Skip to content

Commit

Permalink
chore(misc): update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysoo committed Feb 7, 2025
1 parent efaf61c commit 5bf8645
Show file tree
Hide file tree
Showing 2 changed files with 174 additions and 3 deletions.
165 changes: 165 additions & 0 deletions packages/jest/src/plugins/__snapshots__/plugin.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,61 @@ exports[`@nx/jest/plugin should add package as externalDependencies to the input
]
`;

exports[`@nx/jest/plugin should add package as externalDependencies to the inputs when specified as preset and containing a jest-preset.cjs file 2`] = `
[
[
"proj/jest.config.js",
{
"projects": {
"proj": {
"metadata": undefined,
"root": "proj",
"targets": {
"test": {
"cache": true,
"command": "jest",
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"jest",
"some-package",
],
},
],
"metadata": {
"description": "Run Jest Tests",
"help": {
"command": "npx jest --help",
"example": {
"options": {
"coverage": true,
},
},
},
"technologies": [
"jest",
],
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
],
},
},
},
},
},
],
]
`;

exports[`@nx/jest/plugin should add package as externalDependencies to the inputs when specified as preset and containing a jest-preset.js file 1`] = `
[
[
Expand Down Expand Up @@ -110,6 +165,61 @@ exports[`@nx/jest/plugin should add package as externalDependencies to the input
]
`;

exports[`@nx/jest/plugin should add package as externalDependencies to the inputs when specified as preset and containing a jest-preset.js file 2`] = `
[
[
"proj/jest.config.js",
{
"projects": {
"proj": {
"metadata": undefined,
"root": "proj",
"targets": {
"test": {
"cache": true,
"command": "jest",
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"jest",
"some-package",
],
},
],
"metadata": {
"description": "Run Jest Tests",
"help": {
"command": "npx jest --help",
"example": {
"options": {
"coverage": true,
},
},
},
"technologies": [
"jest",
],
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
],
},
},
},
},
},
],
]
`;

exports[`@nx/jest/plugin should add package as externalDependencies to the inputs when specified as preset and containing a jest-preset.json file 1`] = `
[
[
Expand Down Expand Up @@ -164,3 +274,58 @@ exports[`@nx/jest/plugin should add package as externalDependencies to the input
],
]
`;

exports[`@nx/jest/plugin should add package as externalDependencies to the inputs when specified as preset and containing a jest-preset.json file 2`] = `
[
[
"proj/jest.config.js",
{
"projects": {
"proj": {
"metadata": undefined,
"root": "proj",
"targets": {
"test": {
"cache": true,
"command": "jest",
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"jest",
"some-package",
],
},
],
"metadata": {
"description": "Run Jest Tests",
"help": {
"command": "npx jest --help",
"example": {
"options": {
"coverage": true,
},
},
},
"technologies": [
"jest",
],
},
"options": {
"cwd": "proj",
"env": {
"TS_NODE_COMPILER_OPTIONS": "{"moduleResolution":"node10"}",
},
},
"outputs": [
"{workspaceRoot}/coverage",
],
},
},
},
},
},
],
]
`;
12 changes: 9 additions & 3 deletions packages/jest/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jest.mock('nx/src/utils/cache-directory', () => ({
workspaceDataDirectory: 'tmp/project-graph-cache',
}));

describe('@nx/jest/plugin', () => {
describe.each([true, false])('@nx/jest/plugin', (disableJestRuntime) => {
let createNodesFunction = createNodesV2[1];
let context: CreateNodesContext;
let tempFs: TempFs;
Expand Down Expand Up @@ -54,6 +54,7 @@ describe('@nx/jest/plugin', () => {
['proj/jest.config.js'],
{
targetName: 'test',
disableJestRuntime,
},
context
);
Expand Down Expand Up @@ -127,6 +128,7 @@ describe('@nx/jest/plugin', () => {
{
targetName: 'test',
ciTargetName: 'test-ci',
disableJestRuntime,
},
context
);
Expand Down Expand Up @@ -272,7 +274,7 @@ describe('@nx/jest/plugin', () => {

const results = await createNodesFunction(
['proj/jest.config.js'],
{ targetName: 'test' },
{ targetName: 'test', disableJestRuntime },
context
);

Expand Down Expand Up @@ -352,7 +354,7 @@ describe('@nx/jest/plugin', () => {

const results = await createNodesFunction(
['proj/jest.config.js'],
{ targetName: 'test' },
{ targetName: 'test', disableJestRuntime },
context
);

Expand All @@ -375,6 +377,7 @@ describe('@nx/jest/plugin', () => {
{
ciTargetName: 'test-ci',
ciGroupName: 'MY ATOMIZED TEST TASKS (CI)',
disableJestRuntime,
},
context
);
Expand Down Expand Up @@ -526,6 +529,7 @@ describe('@nx/jest/plugin', () => {
['proj/jest.config.js'],
{
ciTargetName: 'test-ci',
disableJestRuntime,
},
context
);
Expand Down Expand Up @@ -789,6 +793,7 @@ describe('@nx/jest/plugin', () => {
['proj/jest.config.js'],
{
ciTargetName: 'test-ci',
disableJestRuntime,
},
context
);
Expand Down Expand Up @@ -938,6 +943,7 @@ describe('@nx/jest/plugin', () => {
['proj/jest.config.js'],
{
ciTargetName: 'testci', // missing "-ci" suffix or similar construct, so group name cannot reliably be deducted from ci target name
disableJestRuntime,
},
context
);
Expand Down

0 comments on commit 5bf8645

Please sign in to comment.