Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(web): support
baseHref
on serve (#3639)
ISSUES CLOSED: #3553
- Loading branch information
Showing
6 changed files
with
81 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/web/src/builders/dev-server/dev-server.impl.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { MockBuilderContext } from '@nrwl/workspace/testing'; | ||
import { getMockContext } from '../../utils/testing'; | ||
import { EMPTY } from 'rxjs'; | ||
import * as normalizeUtils from '../../utils/normalize'; | ||
import { WebBuildBuilderOptions } from '../build/build.impl'; | ||
import { run, WebDevServerOptions } from './dev-server.impl'; | ||
|
||
jest.mock('@angular-devkit/build-webpack', () => ({ | ||
runWebpackDevServer: () => EMPTY, | ||
})); | ||
|
||
jest.mock('../../utils/devserver.config', () => ({ | ||
getDevServerConfig: jest.fn().mockReturnValue({}), | ||
})); | ||
|
||
describe('Web Server Builder', () => { | ||
let context: MockBuilderContext; | ||
let options: WebDevServerOptions; | ||
|
||
beforeEach(async () => { | ||
context = await getMockContext(); | ||
context.getProjectMetadata = jest | ||
.fn() | ||
.mockReturnValue({ sourceRoot: '/root/app/src' }); | ||
|
||
options = { | ||
buildTarget: 'app:build', | ||
port: 4200, | ||
} as WebDevServerOptions; | ||
|
||
jest | ||
.spyOn(normalizeUtils, 'normalizeWebBuildOptions') | ||
.mockReturnValue({} as WebBuildBuilderOptions); | ||
}); | ||
|
||
it('should pass `baseHref` to build', async () => { | ||
const baseHref = '/my-domain'; | ||
await run({ ...options, baseHref }, context).toPromise(); | ||
|
||
expect(normalizeUtils.normalizeWebBuildOptions).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
baseHref, | ||
}), | ||
'/root', | ||
'/root/app/src' | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters