Skip to content

Commit

Permalink
test(plugins): focused plugin loading on cjs plugins for the time being
Browse files Browse the repository at this point in the history
i think the implementation should support loading of esm plugins as well, but we should add test
coverage for those scenarios as a follow up

for #2543
  • Loading branch information
travi committed Oct 7, 2022
1 parent 56a6679 commit 291eaf8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
@@ -1,4 +1,4 @@
export default {
module.exports = {
verifyConditions: () => {},
getLastRelease: () => {},
analyzeCommits: () => {},
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/plugin-noop.cjs
@@ -0,0 +1 @@
module.exports = () => {};
1 change: 0 additions & 1 deletion test/fixtures/plugin-noop.js

This file was deleted.

18 changes: 9 additions & 9 deletions test/plugins/plugins.test.js
Expand Up @@ -35,9 +35,9 @@ test('Export plugins based on steps config', async (t) => {
cwd,
logger: t.context.logger,
options: {
verifyConditions: ['./test/fixtures/plugin-noop', {path: './test/fixtures/plugin-noop'}],
generateNotes: './test/fixtures/plugin-noop',
analyzeCommits: {path: './test/fixtures/plugin-noop'},
verifyConditions: ['./test/fixtures/plugin-noop.cjs', {path: './test/fixtures/plugin-noop.cjs'}],
generateNotes: './test/fixtures/plugin-noop.cjs',
analyzeCommits: {path: './test/fixtures/plugin-noop.cjs'},
verifyRelease: () => {},
},
},
Expand Down Expand Up @@ -139,7 +139,7 @@ test('Unknown steps of plugins configured in "plugins" are ignored', async (t) =
test('Export plugins loaded from the dependency of a shareable config module', async (t) => {
const cwd = temporaryDirectory();
await copy(
'./test/fixtures/plugin-noop.js',
'./test/fixtures/plugin-noop.cjs',
path.resolve(cwd, 'node_modules/shareable-config/node_modules/custom-plugin/index.js')
);
await outputFile(path.resolve(cwd, 'node_modules/shareable-config/index.js'), '');
Expand Down Expand Up @@ -171,17 +171,17 @@ test('Export plugins loaded from the dependency of a shareable config module', a

test('Export plugins loaded from the dependency of a shareable config file', async (t) => {
const cwd = temporaryDirectory();
await copy('./test/fixtures/plugin-noop.js', path.resolve(cwd, 'plugin/plugin-noop.js'));
await copy('./test/fixtures/plugin-noop.cjs', path.resolve(cwd, 'plugin/plugin-noop.cjs'));
await outputFile(path.resolve(cwd, 'shareable-config.js'), '');

const plugins = await getPlugins(
{
cwd,
logger: t.context.logger,
options: {
verifyConditions: ['./plugin/plugin-noop', {path: './plugin/plugin-noop'}],
generateNotes: './plugin/plugin-noop',
analyzeCommits: {path: './plugin/plugin-noop'},
verifyConditions: ['./plugin/plugin-noop.cjs', {path: './plugin/plugin-noop.cjs'}],
generateNotes: './plugin/plugin-noop.cjs',
analyzeCommits: {path: './plugin/plugin-noop.cjs'},
verifyRelease: () => {},
},
},
Expand Down Expand Up @@ -289,7 +289,7 @@ test('Throw EPLUGINSCONF error if the "plugins" option contains an old plugin de
{
cwd,
logger: t.context.logger,
options: {plugins: ['./test/fixtures/multi-plugin', './test/fixtures/plugin-noop', () => {}]},
options: {plugins: ['./test/fixtures/multi-plugin.cjs', './test/fixtures/plugin-noop.cjs', () => {}]},
},
{}
)
Expand Down
4 changes: 2 additions & 2 deletions test/plugins/utils.test.js
Expand Up @@ -194,9 +194,9 @@ test('loadPlugin', async (t) => {
const cwd = process.cwd();
const func = () => {};

t.is((await import('../fixtures/plugin-noop.js')).default, await loadPlugin({cwd: './test/fixtures'}, './plugin-noop', {}), 'From cwd');
t.is((await import('../fixtures/plugin-noop.cjs')).default, await loadPlugin({cwd: './test/fixtures'}, './plugin-noop', {}), 'From cwd');
t.is(
(await import('../fixtures/plugin-noop.js')).default,
(await import('../fixtures/plugin-noop.cjs')).default,
await loadPlugin({cwd}, './plugin-noop', {'./plugin-noop': './test/fixtures'}),
'From a shareable config context'
);
Expand Down

0 comments on commit 291eaf8

Please sign in to comment.