(hm)
| 1669 | |
| 1670 | describe('recovery from duplicate module IDs', () => { |
| 1671 | async function setupDuplicates(hm) { |
| 1672 | mockFs[path.join('/', 'project', 'fruits', 'Pear.js')] = ` |
| 1673 | // Pear! |
| 1674 | `; |
| 1675 | mockFs[path.join('/', 'project', 'fruits', 'another', 'Pear.js')] = ` |
| 1676 | // Pear too! |
| 1677 | `; |
| 1678 | const e = mockEmitters[path.join('/', 'project', 'fruits')]; |
| 1679 | e.emit( |
| 1680 | 'all', |
| 1681 | 'change', |
| 1682 | 'Pear.js', |
| 1683 | path.join('/', 'project', 'fruits'), |
| 1684 | MOCK_STAT_FILE, |
| 1685 | ); |
| 1686 | e.emit( |
| 1687 | 'all', |
| 1688 | 'add', |
| 1689 | 'Pear.js', |
| 1690 | path.join('/', 'project', 'fruits', 'another'), |
| 1691 | MOCK_STAT_FILE, |
| 1692 | ); |
| 1693 | const {hasteFS, moduleMap} = await waitForItToChange(hm); |
| 1694 | expect( |
| 1695 | hasteFS.exists( |
| 1696 | path.join('/', 'project', 'fruits', 'another', 'Pear.js'), |
| 1697 | ), |
| 1698 | ).toBe(true); |
| 1699 | try { |
| 1700 | moduleMap.getModule('Pear'); |
| 1701 | throw new Error('should be unreachable'); |
| 1702 | } catch (error) { |
| 1703 | const {DuplicateHasteCandidatesError} = |
| 1704 | require('../ModuleMap').default; |
| 1705 | expect(error).toBeInstanceOf(DuplicateHasteCandidatesError); |
| 1706 | expect(error.hasteName).toBe('Pear'); |
| 1707 | expect(error.platform).toBe('g'); |
| 1708 | expect(error.supportsNativePlatform).toBe(false); |
| 1709 | expect(error.duplicatesSet).toEqual( |
| 1710 | createMap({ |
| 1711 | [path.join('/', 'project', 'fruits', 'Pear.js')]: H.MODULE, |
| 1712 | [path.join('/', 'project', 'fruits', 'another', 'Pear.js')]: |
| 1713 | H.MODULE, |
| 1714 | }), |
| 1715 | ); |
| 1716 | expect(error.message.replaceAll('\\', '/')).toMatchSnapshot(); |
| 1717 | } |
| 1718 | } |
| 1719 | |
| 1720 | hm_it( |
| 1721 | 'recovers when the oldest version of the duplicates is fixed', |
no test coverage detected