Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests on master fail when project is cloned locally #218

Open
sehnsucht13 opened this issue Apr 2, 2021 · 1 comment
Open

Tests on master fail when project is cloned locally #218

sehnsucht13 opened this issue Apr 2, 2021 · 1 comment

Comments

@sehnsucht13
Copy link

sehnsucht13 commented Apr 2, 2021

Describe the bug
When the project is cloned from the master branch, one of the test suites fails.

To Reproduce
Steps to reproduce the behavior:

  1. Clone this project
  2. run npm install
  3. run npm run test
  4. Two tests for src/readme.spec.js should fail. They should be:
    1. should return readme default template no html content
    2. should return readme default template content

Expected behavior
Tests should not fail when the project is cloned from the master branch.

Desktop (please complete the following information):

  • OS: Linux, Manjaro
  • Browse Firefox
  • Version 86.0

Additional context
The issue seems to be caused by the snapshot README file in src/__snapshots__ folder. The two lines in the file causing the problem are:

  1. Copyright © 2019 [Franck Abgrall](https://github.com/kefranabg).<br />
  2. Copyright © 2019 [Franck Abgrall](https://github.com/kefranabg).

One of the offending tests is this one:

it('should return readme default template no html content', async () => {
      const result = await buildReadmeContent(
        context,
        defaultNoHtmlTemplatePath
      )

      expect(result).toMatchSnapshot()
    })

It seems like the readme built for test contains a copyright year of 2021 instead of 2019.

@sehnsucht13
Copy link
Author

sehnsucht13 commented Apr 2, 2021

The failing tests can instead be change to this:

    it('should return readme default template no html content', async () => {
      const result = await buildReadmeContent(
        context,
        defaultNoHtmlTemplatePath
      )
      const currentDate = new Date()
      expect(
        result.replace(currentDate.getFullYear(), '2019')
      ).toMatchSnapshot()
    })

This approach will let the original snapshot pass the tests. Another approach is to change the year within the snapshot but that would require updating the snapshot every year.

Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@sehnsucht13 and others