Skip to content

Commit 998f29a

Browse files
committed
test(integration): improved stubbing of the use of conventional-changelog-writer
however stubbing with testdouble appears to not handle streams well
1 parent 40f7596 commit 998f29a

File tree

5 files changed

+31
-27
lines changed

5 files changed

+31
-27
lines changed

index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { find, merge } from 'lodash-es';
33
import getStream from 'get-stream';
44
import intoStream from 'into-stream';
55
import { sync as parser } from 'conventional-commits-parser';
6-
import writer from 'conventional-changelog-writer';
6+
import writer from './wrappers/conventional-changelog-writer.js';
77
import filter from 'conventional-commits-filter';
88
import {readPackageUp} from 'read-pkg-up';
99
import debugFactory from 'debug';
@@ -17,7 +17,7 @@ const debug = debugFactory('semantic-release:release-notes-generator');
1717
*
1818
* @param {Object} pluginConfig The plugin configuration.
1919
* @param {String} pluginConfig.preset conventional-changelog preset ('angular', 'atom', 'codemirror', 'ember', 'eslint', 'express', 'jquery', 'jscs', 'jshint').
20-
* @param {String} pluginConfig.config Requierable npm package with a custom conventional-changelog preset
20+
* @param {String} pluginConfig.config Requireable npm package with a custom conventional-changelog preset
2121
* @param {Object} pluginConfig.parserOpts Additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
2222
* @param {Object} pluginConfig.writerOpts Additional `conventional-changelog-writer` options that will overwrite ones loaded by `preset` or `config`.
2323
* @param {Object} context The semantic-release context.
@@ -88,6 +88,5 @@ export async function generateNotes(pluginConfig, context) {
8888
debug('issue: %o', changelogContext.issue);
8989
debug('commit: %o', changelogContext.commit);
9090

91-
console.log({writer})
9291
return getStream(intoStream.object(parsedCommits).pipe(writer(changelogContext, writerOpts)));
9392
}

package-lock.json

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"fs-extra": "10.0.0",
3636
"semantic-release": "20.1.0",
3737
"tempy": "^2.0.0",
38-
"testdouble": "3.16.3",
38+
"testdouble": "3.16.8",
3939
"xo": "0.39.1"
4040
},
4141
"engines": {
@@ -94,7 +94,7 @@
9494
"type": "module",
9595
"ava": {
9696
"nodeArguments": [
97-
"--loader=quibble",
97+
"--loader=testdouble",
9898
"--no-warnings"
9999
]
100100
},

test/integration.test.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import fs from 'fs-extra';
44
import escape from 'escape-string-regexp';
55
import tempy from 'tempy';
66
import * as td from 'testdouble';
7-
import { generateNotes } from '../index.js';
87
import { promisify } from 'node:util';
98

109
const cwd = process.cwd();
@@ -15,6 +14,13 @@ const repositoryUrl = `${host}/${owner}/${repository}`;
1514
const lastRelease = {gitTag: 'v1.0.0'};
1615
const nextRelease = {gitTag: 'v2.0.0', version: '2.0.0'};
1716

17+
let generateNotes, writer;
18+
19+
test.beforeEach(async () => {
20+
(writer = await td.replaceEsm('../wrappers/conventional-changelog-writer.js'));
21+
({generateNotes} = await import('../index.js'));
22+
});
23+
1824
test.afterEach(() => {
1925
td.reset();
2026
});
@@ -38,8 +44,6 @@ test('Use "conventional-changelog-angular" by default', async (t) => {
3844

3945
test('Set conventional-changelog-writer context', async (t) => {
4046
const cwd = tempy.directory();
41-
const writer = td.replace('conventional-changelog-writer');
42-
const {generateNotes} = await import('../index.js');
4347

4448
const commits = [
4549
{hash: '111', message: 'fix(scope1): First fix'},
@@ -64,8 +68,6 @@ test('Set conventional-changelog-writer context', async (t) => {
6468

6569
test('Set conventional-changelog-writer context with package.json', async (t) => {
6670
const cwd = tempy.directory();
67-
const writer = await td.replaceEsm('conventional-changelog-writer');
68-
const {generateNotes} = await import('../index.js');
6971

7072
const packageData = {name: 'package', version: '0.0.0'};
7173
await fs.outputJson(path.resolve(cwd, 'package.json'), packageData);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import writer from 'conventional-changelog-writer';
2+
3+
export default writer;

0 commit comments

Comments
 (0)