rollup-plugin-preserve-shebang icon indicating copy to clipboard operation
rollup-plugin-preserve-shebang copied to clipboard

test: add integration tests

Open radiovisual opened this issue 3 months ago • 1 comments

This plugin is missing tests, so I wrote some integration tests that test the plugin with rollup.

Changes

  • Adds integration tests in rollup + plugin
  • Adds a github workflow file to run tests in PRs and merge to master
  • Adds a status badge to the README
  • Fixed a bug that breaks the build if there is whitespace leading the shebang (and corrects the problem by removing the leading whitespace)
  • Updated the README (including removing mention of unsupported code)
  • Adds a status badge to the README

Workflow status

Here is proof that the tests are running and passing on my branch:

Pasted Graphic 4

and here is the status badge:

image

WDYT @developit ?

radiovisual avatar Mar 09 '24 23:03 radiovisual

Also, according to the README, there is a feature mentioned that you can override the entry file, but that feature seems to have been removed in this commit.

I had this test written for the feature, but of course it was failing, since the feature is not supported:

	it('should override the entry file if a new one is supplied', async () => {
		const inputFilePath = getFixtureFilePath('no-shebang.js');
		const bundle = await getRollUpBundle(inputFilePath, {
			entry: getFixtureFilePath('hello-world-cli.js')
		});
		const generatedCode = await getGeneratedContent(bundle, format);

		expect(generatedCode.split('\n')[0]).toEqual(nodeShebang);
		expect(generatedCode).toMatchSnapshot();
	});

I removed the mention of the unsupported feature via https://github.com/developit/rollup-plugin-preserve-shebang/pull/16/commits/0b0116bf863bec4d1822ac0bfde08f0d0674cc42

radiovisual avatar Mar 10 '24 09:03 radiovisual