-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nx-update-ts-references: Create plugin integration test
- Loading branch information
Showing
2 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
apps/nx-update-ts-references/src/tests/integration/plugin.spec.ts
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,83 @@ | ||
import Path from 'node:path'; | ||
import { createProjectGraphAsync, type ExecutorContext } from '@nx/devkit'; | ||
import type { Context } from 'mocha'; | ||
import { before, suite } from 'mocha-chain'; | ||
import executor from '../../executors/update-ts-references/index.cjs'; | ||
import { expect } from '../chai-hooks.js'; | ||
|
||
const handler = executor.default; | ||
|
||
suite('plugin', () => { | ||
const withExecutorContext = before(async function (this: Context) { | ||
this.timeout(2000); | ||
const projectGraph = await createProjectGraphAsync(); | ||
return { | ||
projectGraph, | ||
defaultSettings: { | ||
projectName: 'nx-update-ts-references', | ||
root: Path.join(import.meta.dirname, '../../../../..'), | ||
nxJsonConfiguration: {}, | ||
projectsConfigurations: { | ||
version: 123, | ||
projects: {}, | ||
}, | ||
cwd: process.cwd(), | ||
isVerbose: false, | ||
projectGraph, | ||
} satisfies ExecutorContext, | ||
}; | ||
}); | ||
|
||
withExecutorContext.test('success', async ({ defaultSettings }) => { | ||
expect( | ||
await handler( | ||
{ | ||
check: true, | ||
dryRun: true, | ||
}, | ||
defaultSettings | ||
) | ||
).to.deep.equal({ success: true }); | ||
}); | ||
|
||
suite('Out of sync', () => { | ||
const withInvalidContext = withExecutorContext.before( | ||
({ defaultSettings, projectGraph }) => ({ | ||
errorSettings: { | ||
...defaultSettings, | ||
projectGraph: { | ||
...projectGraph, | ||
dependencies: { | ||
...projectGraph.dependencies, | ||
'nx-update-ts-references': [], | ||
}, | ||
}, | ||
}, | ||
}) | ||
); | ||
|
||
withInvalidContext.test('Fails when check is enabled', async ({ errorSettings }) => { | ||
expect( | ||
await handler( | ||
{ | ||
check: true, | ||
dryRun: false, | ||
}, | ||
errorSettings | ||
) | ||
).to.deep.equal({ success: false }); | ||
}); | ||
|
||
withInvalidContext.test('Passes when dryRun is enabled', async ({ errorSettings }) => { | ||
expect( | ||
await handler( | ||
{ | ||
check: false, | ||
dryRun: true, | ||
}, | ||
errorSettings | ||
) | ||
).to.deep.equal({ success: true }); | ||
}); | ||
}); | ||
}); |
7 changes: 0 additions & 7 deletions
7
apps/nx-update-ts-references/src/tests/unit/executors/update-ts-references/index.spec.ts
This file was deleted.
Oops, something went wrong.