Skip to content

Commit

Permalink
feat(mappings): change precedence (FIX #42)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBuchholz committed Mar 23, 2023
1 parent 9b7b26e commit 7cc8e8a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reserve.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = job => check({
port: job.port,
mappings: [
cors,
...job.mappings ?? [],
...job.serveOnly ? [] : endpoints(job),
...ui5(job),
...job.serveOnly ? [] : coverage(job), {
Expand All @@ -19,7 +20,6 @@ module.exports = job => check({
strict: true,
'ignore-if-not-found': true
},
...job.mappings ?? [],
...unhandled(job)
]
})
29 changes: 29 additions & 0 deletions src/simulate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,35 @@ describe('simulate', () => {
}
}

describe.only('mappings', () => {
beforeAll(async () => {
await setup('mappings', {
mappings: [
'/overridden/resources/(.*)=file(./LICENSE)'
]
})
})

const urls = [
'/webapp/resources/sap-ui-core.js',
'/resources/sap-ui-core.js',
'/custom/resources/sap-ui-core.js'
]
urls.forEach(url => {
it(`fetches UI5 resources whichever path is used (${url})`, async () => {
const response = await get(url, 'test.html')
expect(response.statusCode).toStrictEqual(200)
expect(response.toString().includes('/sap-ui-core.js */')).toStrictEqual(true)
})
})

it('enables overridding through mappings', async () => {
const response = await get('/overridden/resources/sap-ui-core.js', 'test.html')
expect(response.statusCode).toStrictEqual(200)
expect(response.toString().startsWith('MIT License')).toStrictEqual(true)
})
})

describe('legacy (local project)', () => {
describe('simple test execution', () => {
beforeAll(async () => {
Expand Down

0 comments on commit 7cc8e8a

Please sign in to comment.