Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ const getFramework = async function (frameworkId, context) {
const getFrameworkById = function (frameworkId) {
const framework = FRAMEWORKS.find(({ id }) => id === frameworkId)
if (framework === undefined) {
const frameworkIds = FRAMEWORKS.map((knownFramework) => getFrameworkId(knownFramework)).join(', ')
const frameworkIds = FRAMEWORKS.map((knownFramework) => getFrameworkId(knownFramework))
.sort()
.join(', ')
throw new Error(`Invalid framework "${frameworkId}". It should be one of: ${frameworkIds}`)
}
return framework
Expand Down
10 changes: 10 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,13 @@ test('Should allow testing a specific framework', async (t) => {
test('Should throw when testing an invalid framework', async (t) => {
await t.throwsAsync(hasFramework('simple', 'doesNotExist'))
})

test('Should sort framework ids in invalid framework error message', async (t) => {
const error = await t.throwsAsync(hasFramework('simple', 'doesNotExist'))

// we don't use a hardcoded string here, since it will change when a new framework is added
const [, frameworksFromMessage] = error.message.match(/It should be one of: (.+)/)
const frameworksArray = frameworksFromMessage.split(', ')

t.deepEqual(frameworksArray, [...frameworksArray].sort())
})