Skip to content

USWDS - Unit Tests: Build and Include unit tests are not being ran. #6294

Description

@mahoneycm

Description

Tests found in src/test directory are not currently being ran at any point. Additional inspection from @aduth revealed the tests do not pass in their current state.

Problem statement

These tests were added in #1530, from 2016, when all.scss was renamed to uswds.scss. They are supposed to verify:

  • Running gulp build generates the expected uswds.css and uswds.min.css files with the correct version number string
  • Importing uswds or all from the include path doesn’t generate an error

Not having these tests could cause unintentional regressions to float through such as the version number not outputting correctly, or issues importing USWDS Sass.

Expected behavior

All unit tests should run and complete without failure.

Next steps

  • Update tests to reflect modern USWDS repo structure
  • Get tests to pass
  • Decide when we should run these tests

Additional information

From discussion in #6171:

@mahoneycm I started working on this and it turned into quite a rabbit-hole, since the current tests do not pass as-is.

You can check this by running them directly:

npm exec mocha src/test/include.spec.js src/test/build.spec.js

There's a number of preexisting issues:

  • The tests include timeouts which run after very long delays, without anything telling Mocha to wait for their results, perhaps giving false positives on test results
  • Test utility paths are outdated and seem to reflect the pre-packages folder structure
  • The tests reference Gulp tasks which no longer exist (sass, copy-dist-sass)
  • The tests are meant to verify that node_modules/@uswds/uswds/dist is supported as a load path for Sass, but this is actually broken in the published package (the relative path referenced in dist/scss/stylesheets/uswds.scss does not exist)

I've fixed most of these in my local copy of this branch, except for the issues with dist/scss, which are harder to solve.

Perhaps the dist/scss folder should be removed altogether? It doesn't seem to work, the documentation only mentions pacakges, and there's an inline comment referencing the fact that copying scss may not be needed:

// TODO: Do we want to copy to the scss any more?

Originally posted by @aduth in #6171 (comment)

Metadata

Metadata

Assignees

Labels

Affects: TestingRelates to code testingComplete before freezeFinish these before the USWDS 3 code freezeContext: JavaScriptIssue is in JavaScriptType: SpikeNeeds or is in process of a short research activity to help make a decision

Type

Fields

No fields configured for Bug.

Projects

Status
In progress

Relationships

None yet

Development

No branches or pull requests

Issue actions