deep-exports.test.ts 946 B

12345678910111213141516171819202122232425262728
  1. import { expect } from 'chai';
  2. /**
  3. * Tests whether users can import files deeper than '@sequelize/core" (eg. "@sequelize/core/package.json').
  4. * Context: https://github.com/sequelize/sequelize/issues/13787
  5. */
  6. describe('exports', () => {
  7. it('exposes /package.json', async () => {
  8. // TODO: uncomment test once https://nodejs.org/api/esm.html#json-modules are stable
  9. // await import('@sequelize/core/package.json', {
  10. // assert: { type: 'json' }
  11. // });
  12. require('@sequelize/core/package.json');
  13. });
  14. it('blocks access to lib files', async () => {
  15. // @ts-expect-error -- we're testing that this will be rejected
  16. await expect(import('@sequelize/core/lib/model')).to.be.rejectedWith(
  17. 'ERR_PACKAGE_PATH_NOT_EXPORTED',
  18. );
  19. });
  20. it('allows access to lib if the user acknowledges that it is unsafe', async () => {
  21. await import('@sequelize/core/_non-semver-use-at-your-own-risk_/model.js');
  22. });
  23. });