-
-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update cosmos.modules file on fixture file changes (#735)
- Loading branch information
Showing
17 changed files
with
241 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
require('crna-make-symlinks-for-yarn-workspaces')(__dirname); | ||
require('@skidding/crna-make-symlinks-for-yarn-workspaces')(__dirname); |
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
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
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
65 changes: 65 additions & 0 deletions
65
packages/react-cosmos/src/server/native/__tests__/start-new-fixture.js
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,65 @@ | ||
/** | ||
* @flow | ||
* @jest-environment node | ||
*/ | ||
|
||
import { join } from 'path'; | ||
import { readFile, copy, remove } from 'fs-extra'; | ||
import until from 'async-until'; | ||
import { | ||
defaultFileMatch as mockFileMatch, | ||
defaultFileMatchIgnore as mockFileMatchIgnore, | ||
defaultExclude as mockExclude | ||
} from 'react-cosmos-shared/server'; | ||
import { startServer } from '../start'; | ||
|
||
const mockRootPath = join(__dirname, '__fsmocks__'); | ||
const mockProxiesPath = join(mockRootPath, 'cosmos.proxies'); | ||
const mockNewFixturePath = join(mockRootPath, 'jestnowatch.fixture.js'); | ||
const mockModulesPath = join(__dirname, '__fsoutput__/cosmos.modules.js'); | ||
|
||
jest.mock('react-cosmos-config', () => ({ | ||
getCosmosConfig: () => ({ | ||
rootPath: mockRootPath, | ||
port: 10002, | ||
hostname: null, | ||
publicUrl: '/', | ||
fileMatch: mockFileMatch, | ||
fileMatchIgnore: mockFileMatchIgnore, | ||
exclude: mockExclude, | ||
proxiesPath: mockProxiesPath, | ||
modulesPath: mockModulesPath | ||
}) | ||
})); | ||
|
||
let stopServer; | ||
|
||
beforeEach(async () => { | ||
jest.clearAllMocks(); | ||
stopServer = await startServer(); | ||
}); | ||
|
||
afterEach(async () => { | ||
await stopServer(); | ||
await remove(mockModulesPath); | ||
await remove(mockNewFixturePath); | ||
}); | ||
|
||
it('re-generates modules file on new fixture file ', async () => { | ||
expect((await getFixtureFilesFromModules()).length).toBe(1); | ||
|
||
await copy(join(mockRootPath, 'MyComponent.fixture.js'), mockNewFixturePath); | ||
|
||
// Wait for fs event to be picked up | ||
await until(async () => (await getFixtureFilesFromModules()).length === 2, { | ||
loopDelay: 200, | ||
timeout: 2000, | ||
failMsg: 'cosmos.modules file has not been updated' | ||
}); | ||
}); | ||
|
||
async function getFixtureFilesFromModules() { | ||
const output = await readFile(mockModulesPath, 'utf8'); | ||
|
||
return JSON.parse(output.match(/fixtureFiles: (.+?),\n/)[1]); | ||
} |
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
2 changes: 1 addition & 1 deletion
2
packages/react-cosmos/src/server/web/webpack/extend-webpack-config.js
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
Oops, something went wrong.