Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test deprecations in legacy JS API #2006

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions js-api-spec/legacy/render.node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,90 @@ describe('options', () => {
});
});

describe('fatalDeprecations', () => {
it('makes specified deprecations fatal', () => {
expect(() =>
sass.renderSync({
data: '$_: 1/2;',
fatalDeprecations: ['slash-div'],
})
).toThrowLegacyException({includes: 'math.div'});
});

it('leaves other deprecations as warnings', () => {
const stdio = captureStdio(() =>
sass.renderSync({
data: '$_: 1/2;',
fatalDeprecations: ['call-string'],
})
);
expect(stdio.out).toBeEmptyString();
expect(stdio.err).toContain('math.div');
});
});

describe('futureDeprecations', () => {
it('opts into future deprecation early', () => {
sandbox(dir => {
dir.write({
'test.scss': '@import "other";',
'_other.scss': '',
});

const stdio = captureStdio(() =>
sass.renderSync({
file: dir('test.scss'),
// data: '@import "other"',
futureDeprecations: ['import'],
})
);
expect(stdio.out).toBeEmptyString();
expect(stdio.err).toContain('@import rule');
});
});

it('emits no warning when not set', () => {
sandbox(dir => {
dir.write({
'test.scss': '@import "other";',
'_other.scss': '',
});

const stdio = captureStdio(() =>
sass.renderSync({
file: dir('test.scss'),
})
);
expect(stdio.out).toBeEmptyString();
expect(stdio.err).toBeEmptyString();
});
});
});

describe('silenceDeprecations', () => {
it('hides specified deprecation warnings', () => {
const stdio = captureStdio(() =>
sass.renderSync({
data: '$_: 1/2;',
silenceDeprecations: ['slash-div'],
})
);
expect(stdio.out).toBeEmptyString();
expect(stdio.err).toBeEmptyString();
});

it('emits other deprecation warnings', () => {
const stdio = captureStdio(() =>
sass.renderSync({
data: '$_: 1/2;',
silenceDeprecations: ['call-string'],
})
);
expect(stdio.out).toBeEmptyString();
expect(stdio.err).toContain('math.div');
});
});

describe('verbose', () => {
const data = `
$_: call("inspect", null);
Expand Down
Loading