Skip to content

Commit

Permalink
chore(bundling): fix plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Dec 11, 2024
1 parent 11924ec commit 7eb1d5a
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 6 deletions.
109 changes: 109 additions & 0 deletions packages/rollup/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/rollup/plugin non-root project should create nodes 1`] = `
]
`;

exports[`@nx/rollup/plugin non-root project should create nodes 2`] = `
[
[
"mylib/rollup.config.cts",
{
"projects": {
"mylib": {
"root": "mylib",
"targets": {
"build": {
"cache": true,
"command": "rollup -c rollup.config.cts --configPlugin @rollup/plugin-typescript",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
{
"externalDependencies": [
"rollup",
],
},
],
"metadata": {
"description": "Run Rollup",
"help": {
"command": "npx rollup --help",
"example": {
"options": {
"sourcemap": true,
"watch": true,
},
},
},
"technologies": [
"rollup",
],
},
"options": {
"cwd": "mylib",
},
"outputs": [
"{workspaceRoot}/mylib/build",
"{workspaceRoot}/mylib/dist",
],
},
},
},
},
},
],
]
`;

exports[`@nx/rollup/plugin root project should create nodes 1`] = `
[
[
Expand Down Expand Up @@ -108,3 +163,57 @@ exports[`@nx/rollup/plugin root project should create nodes 1`] = `
],
]
`;

exports[`@nx/rollup/plugin root project should create nodes 2`] = `
[
[
"rollup.config.cts",
{
"projects": {
".": {
"root": ".",
"targets": {
"build": {
"cache": true,
"command": "rollup -c rollup.config.cts --configPlugin @rollup/plugin-typescript",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
{
"externalDependencies": [
"rollup",
],
},
],
"metadata": {
"description": "Run Rollup",
"help": {
"command": "npx rollup --help",
"example": {
"options": {
"sourcemap": true,
"watch": true,
},
},
},
"technologies": [
"rollup",
],
},
"options": {
"cwd": ".",
},
"outputs": [
"{workspaceRoot}/dist",
],
},
},
},
},
},
],
]
`;
12 changes: 6 additions & 6 deletions packages/rollup/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('@nx/rollup/plugin', () => {
let context: CreateNodesContext;
let cwd = process.cwd();

describe('root project', () => {
describe.each(['js', 'ts'])('root project', (extname) => {
const tempFs = new TempFs('test');

beforeEach(() => {
Expand Down Expand Up @@ -51,7 +51,7 @@ describe('@nx/rollup/plugin', () => {
// is that the hash is different after updating the
// config file. The actual config read is mocked below.
tempFs.createFileSync(
'rollup.config.cjs',
`rollup.config.c${extname}`,
JSON.stringify(rollupConfigOptions)
);
tempFs.createFileSync('package.json', JSON.stringify({ name: 'mylib' }));
Expand All @@ -77,7 +77,7 @@ describe('@nx/rollup/plugin', () => {
it('should create nodes', async () => {
// ACT
const nodes = await createNodesFunction(
['rollup.config.cjs'],
[`rollup.config.c${extname}`],
{
buildTargetName: 'build',
},
Expand All @@ -89,7 +89,7 @@ describe('@nx/rollup/plugin', () => {
});
});

describe('non-root project', () => {
describe.each(['js', 'ts'])('non-root project', (extname) => {
const tempFs = new TempFs('test');

beforeEach(() => {
Expand Down Expand Up @@ -125,7 +125,7 @@ describe('@nx/rollup/plugin', () => {
// is that the hash is different after updating the
// config file. The actual config read is mocked below.
tempFs.createFileSync(
'mylib/rollup.config.cjs',
`mylib/rollup.config.c${extname}`,
JSON.stringify(rollupConfigOptions)
);
tempFs.createFileSync(
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('@nx/rollup/plugin', () => {
it('should create nodes', async () => {
// ACT
const nodes = await createNodesFunction(
['mylib/rollup.config.cjs'],
[`mylib/rollup.config.c${extname}`],
{
buildTargetName: 'build',
},
Expand Down

0 comments on commit 7eb1d5a

Please sign in to comment.